1 | "use strict";
|
2 | Object.defineProperty(exports, "__esModule", { value: true });
|
3 | exports.getTypeReference = exports.getEnumValueReference = exports.getArgumentReference = exports.getDirectiveReference = exports.getFieldReference = void 0;
|
4 | var graphql_1 = require("graphql");
|
5 | function 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 | }
|
13 | exports.getFieldReference = getFieldReference;
|
14 | function getDirectiveReference(typeInfo) {
|
15 | return {
|
16 | kind: 'Directive',
|
17 | schema: typeInfo.schema,
|
18 | directive: typeInfo.directiveDef,
|
19 | };
|
20 | }
|
21 | exports.getDirectiveReference = getDirectiveReference;
|
22 | function 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 | }
|
38 | exports.getArgumentReference = getArgumentReference;
|
39 | function 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 | }
|
48 | exports.getEnumValueReference = getEnumValueReference;
|
49 | function getTypeReference(typeInfo, type) {
|
50 | return {
|
51 | kind: 'Type',
|
52 | schema: typeInfo.schema,
|
53 | type: type || typeInfo.type,
|
54 | };
|
55 | }
|
56 | exports.getTypeReference = getTypeReference;
|
57 | function isMetaField(fieldDef) {
|
58 | return fieldDef.name.slice(0, 2) === '__';
|
59 | }
|
60 |
|
\ | No newline at end of file |