UNPKG

codemirror-graphql

Version:
59 lines 1.8 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.getFieldReference = getFieldReference; exports.getDirectiveReference = getDirectiveReference; exports.getArgumentReference = getArgumentReference; exports.getEnumValueReference = getEnumValueReference; exports.getTypeReference = getTypeReference; const graphql_1 = require("graphql"); function getFieldReference(typeInfo) { return { kind: 'Field', schema: typeInfo.schema, field: typeInfo.fieldDef, type: isMetaField(typeInfo.fieldDef) ? null : typeInfo.parentType, }; } function getDirectiveReference(typeInfo) { return { kind: 'Directive', schema: typeInfo.schema, directive: typeInfo.directiveDef, }; } function getArgumentReference(typeInfo) { return typeInfo.directiveDef ? { kind: 'Argument', schema: typeInfo.schema, argument: typeInfo.argDef, directive: typeInfo.directiveDef, } : { kind: 'Argument', schema: typeInfo.schema, argument: typeInfo.argDef, field: typeInfo.fieldDef, type: isMetaField(typeInfo.fieldDef) ? null : typeInfo.parentType, }; } function getEnumValueReference(typeInfo) { return { kind: 'EnumValue', value: typeInfo.enumValue || undefined, type: typeInfo.inputType ? (0, graphql_1.getNamedType)(typeInfo.inputType) : undefined, }; } function getTypeReference(typeInfo, type) { return { kind: 'Type', schema: typeInfo.schema, type: type || typeInfo.type, }; } function isMetaField(fieldDef) { return fieldDef.name.slice(0, 2) === '__'; } //# sourceMappingURL=SchemaReference.js.map