123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135 |
- /**
- * Produce the GraphQL query recommended for a full schema introspection.
- * Accepts optional IntrospectionOptions.
- */
- export 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
- }
- }
- }
- }
- }
- }
- }
- }
- }
- }
- `;
- }
|