You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
143 lines
3.1 KiB
143 lines
3.1 KiB
4 months ago
|
'use strict';
|
||
|
|
||
|
Object.defineProperty(exports, '__esModule', {
|
||
|
value: true,
|
||
|
});
|
||
|
exports.getIntrospectionQuery = getIntrospectionQuery;
|
||
|
|
||
|
/**
|
||
|
* Produce the GraphQL query recommended for a full schema introspection.
|
||
|
* Accepts optional IntrospectionOptions.
|
||
|
*/
|
||
|
function getIntrospectionQuery(options) {
|
||
|
const optionsWithDefault = {
|
||
|
descriptions: true,
|
||
|
specifiedByUrl: false,
|
||
|
directiveIsRepeatable: false,
|
||
|
schemaDescription: false,
|
||
|
inputValueDeprecation: false,
|
||
|
...options,
|
||
|
};
|
||
|
const descriptions = optionsWithDefault.descriptions ? 'description' : '';
|
||
|
const specifiedByUrl = optionsWithDefault.specifiedByUrl
|
||
|
? 'specifiedByURL'
|
||
|
: '';
|
||
|
const directiveIsRepeatable = optionsWithDefault.directiveIsRepeatable
|
||
|
? 'isRepeatable'
|
||
|
: '';
|
||
|
const schemaDescription = optionsWithDefault.schemaDescription
|
||
|
? descriptions
|
||
|
: '';
|
||
|
|
||
|
function inputDeprecation(str) {
|
||
|
return optionsWithDefault.inputValueDeprecation ? str : '';
|
||
|
}
|
||
|
|
||
|
return `
|
||
|
query IntrospectionQuery {
|
||
|
__schema {
|
||
|
${schemaDescription}
|
||
|
queryType { name }
|
||
|
mutationType { name }
|
||
|
subscriptionType { name }
|
||
|
types {
|
||
|
...FullType
|
||
|
}
|
||
|
directives {
|
||
|
name
|
||
|
${descriptions}
|
||
|
${directiveIsRepeatable}
|
||
|
locations
|
||
|
args${inputDeprecation('(includeDeprecated: true)')} {
|
||
|
...InputValue
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
fragment FullType on __Type {
|
||
|
kind
|
||
|
name
|
||
|
${descriptions}
|
||
|
${specifiedByUrl}
|
||
|
fields(includeDeprecated: true) {
|
||
|
name
|
||
|
${descriptions}
|
||
|
args${inputDeprecation('(includeDeprecated: true)')} {
|
||
|
...InputValue
|
||
|
}
|
||
|
type {
|
||
|
...TypeRef
|
||
|
}
|
||
|
isDeprecated
|
||
|
deprecationReason
|
||
|
}
|
||
|
inputFields${inputDeprecation('(includeDeprecated: true)')} {
|
||
|
...InputValue
|
||
|
}
|
||
|
interfaces {
|
||
|
...TypeRef
|
||
|
}
|
||
|
enumValues(includeDeprecated: true) {
|
||
|
name
|
||
|
${descriptions}
|
||
|
isDeprecated
|
||
|
deprecationReason
|
||
|
}
|
||
|
possibleTypes {
|
||
|
...TypeRef
|
||
|
}
|
||
|
}
|
||
|
|
||
|
fragment InputValue on __InputValue {
|
||
|
name
|
||
|
${descriptions}
|
||
|
type { ...TypeRef }
|
||
|
defaultValue
|
||
|
${inputDeprecation('isDeprecated')}
|
||
|
${inputDeprecation('deprecationReason')}
|
||
|
}
|
||
|
|
||
|
fragment TypeRef on __Type {
|
||
|
kind
|
||
|
name
|
||
|
ofType {
|
||
|
kind
|
||
|
name
|
||
|
ofType {
|
||
|
kind
|
||
|
name
|
||
|
ofType {
|
||
|
kind
|
||
|
name
|
||
|
ofType {
|
||
|
kind
|
||
|
name
|
||
|
ofType {
|
||
|
kind
|
||
|
name
|
||
|
ofType {
|
||
|
kind
|
||
|
name
|
||
|
ofType {
|
||
|
kind
|
||
|
name
|
||
|
ofType {
|
||
|
kind
|
||
|
name
|
||
|
ofType {
|
||
|
kind
|
||
|
name
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
`;
|
||
|
}
|