UNPKG

graphqldoc

Version:
167 lines (163 loc) 3.29 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.LIST = 'LIST'; exports.NON_NULL = 'NON_NULL'; exports.SCALAR = 'SCALAR'; exports.OBJECT = 'OBJECT'; exports.INTERFACE = 'INTERFACE'; exports.UNION = 'UNION'; exports.ENUM = 'ENUM'; exports.INPUT_OBJECT = 'INPUT_OBJECT'; function getTypeOf(type) { while (type.kind === exports.LIST || type.kind === exports.NON_NULL) type = type.ofType; return type; } exports.getTypeOf = getTypeOf; function getFilenameOf(type) { const name = getTypeOf(type).name.toLowerCase(); if (name[0] === '_' && name[1] === '_') return name.slice(2) + '.spec.html'; return name + '.doc.html'; } exports.getFilenameOf = getFilenameOf; const fullTypeFragment = ` fragment FullType on __Type { fields(includeDeprecated: true) { name description args { ...InputValue } type { ...TypeRef } isDeprecated deprecationReason } inputFields { ...InputValue } interfaces { ...TypeRef } enumValues(includeDeprecated: true) { name description isDeprecated deprecationReason } possibleTypes { ...TypeRef } }`; const inputValueFragment = ` fragment InputValue on __InputValue { name description type { ...TypeRef } defaultValue }`; const typeRefFragment = ` fragment TypeRef on __Type { kind name description ofType { kind name description ofType { kind name description ofType { kind name description ofType { kind name description ofType { kind name description ofType { kind name description ofType { kind name description } } } } } } } }`; exports.query = `query IntrospectionQuery { __schema { queryType { name description kind} mutationType { name description kind } subscriptionType { name description kind } types { name kind description ...FullType } directives { name description locations args { ...InputValue } } } } ${fullTypeFragment} ${inputValueFragment} ${typeRefFragment} `; exports.queryRoot = `query IntrospectionQuery { __schema { queryType { name description kind} mutationType { name description kind } subscriptionType { name description kind } } } `; exports.queryTypes = `query IntrospectionQuery { __schema { types { name kind description ...FullType } } } ${fullTypeFragment} ${inputValueFragment} ${typeRefFragment} `; exports.queryDirectives = `query IntrospectionQuery { __schema { directives { name description locations args { ...InputValue } } } } ${inputValueFragment} ${typeRefFragment} `;