UNPKG

1.96 kBJavaScriptView Raw
1"use strict";
2Object.defineProperty(exports, "__esModule", { value: true });
3exports.getTypeReference = exports.getEnumValueReference = exports.getArgumentReference = exports.getDirectiveReference = exports.getFieldReference = void 0;
4var graphql_1 = require("graphql");
5function getFieldReference(typeInfo) {
6 return {
7 kind: 'Field',
8 schema: typeInfo.schema,
9 field: typeInfo.fieldDef,
10 type: isMetaField(typeInfo.fieldDef) ? null : typeInfo.parentType,
11 };
12}
13exports.getFieldReference = getFieldReference;
14function getDirectiveReference(typeInfo) {
15 return {
16 kind: 'Directive',
17 schema: typeInfo.schema,
18 directive: typeInfo.directiveDef,
19 };
20}
21exports.getDirectiveReference = getDirectiveReference;
22function getArgumentReference(typeInfo) {
23 return typeInfo.directiveDef
24 ? {
25 kind: 'Argument',
26 schema: typeInfo.schema,
27 argument: typeInfo.argDef,
28 directive: typeInfo.directiveDef,
29 }
30 : {
31 kind: 'Argument',
32 schema: typeInfo.schema,
33 argument: typeInfo.argDef,
34 field: typeInfo.fieldDef,
35 type: isMetaField(typeInfo.fieldDef) ? null : typeInfo.parentType,
36 };
37}
38exports.getArgumentReference = getArgumentReference;
39function getEnumValueReference(typeInfo) {
40 return {
41 kind: 'EnumValue',
42 value: typeInfo.enumValue || undefined,
43 type: typeInfo.inputType
44 ? (0, graphql_1.getNamedType)(typeInfo.inputType)
45 : undefined,
46 };
47}
48exports.getEnumValueReference = getEnumValueReference;
49function getTypeReference(typeInfo, type) {
50 return {
51 kind: 'Type',
52 schema: typeInfo.schema,
53 type: type || typeInfo.type,
54 };
55}
56exports.getTypeReference = getTypeReference;
57function isMetaField(fieldDef) {
58 return fieldDef.name.slice(0, 2) === '__';
59}
60//# sourceMappingURL=SchemaReference.js.map
\No newline at end of file