123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278 |
- // @flow strict
- import { type DirectiveLocationEnum } from '../language/directiveLocation';
- export type IntrospectionOptions = {|
- // Whether to include descriptions in the introspection result.
- // Default: true
- descriptions: boolean,
- |};
- export function getIntrospectionQuery(options?: IntrospectionOptions): string {
- const descriptions = !(options && options.descriptions === false);
- return `
- query IntrospectionQuery {
- __schema {
- queryType { name }
- mutationType { name }
- subscriptionType { name }
- types {
- ...FullType
- }
- directives {
- name
- ${descriptions ? 'description' : ''}
- locations
- args {
- ...InputValue
- }
- }
- }
- }
- fragment FullType on __Type {
- kind
- name
- ${descriptions ? 'description' : ''}
- fields(includeDeprecated: true) {
- name
- ${descriptions ? 'description' : ''}
- args {
- ...InputValue
- }
- type {
- ...TypeRef
- }
- isDeprecated
- deprecationReason
- }
- inputFields {
- ...InputValue
- }
- interfaces {
- ...TypeRef
- }
- enumValues(includeDeprecated: true) {
- name
- ${descriptions ? 'description' : ''}
- isDeprecated
- deprecationReason
- }
- possibleTypes {
- ...TypeRef
- }
- }
- fragment InputValue on __InputValue {
- name
- ${descriptions ? 'description' : ''}
- type { ...TypeRef }
- defaultValue
- }
- 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
- }
- }
- }
- }
- }
- }
- }
- }
- `;
- }
- /**
- * Deprecated, call getIntrospectionQuery directly.
- *
- * This function will be removed in v15
- */
- export const introspectionQuery = getIntrospectionQuery();
- export type IntrospectionQuery = {|
- +__schema: IntrospectionSchema,
- |};
- export type IntrospectionSchema = {|
- +queryType: IntrospectionNamedTypeRef<IntrospectionObjectType>,
- +mutationType: ?IntrospectionNamedTypeRef<IntrospectionObjectType>,
- +subscriptionType: ?IntrospectionNamedTypeRef<IntrospectionObjectType>,
- +types: $ReadOnlyArray<IntrospectionType>,
- +directives: $ReadOnlyArray<IntrospectionDirective>,
- |};
- export type IntrospectionType =
- | IntrospectionScalarType
- | IntrospectionObjectType
- | IntrospectionInterfaceType
- | IntrospectionUnionType
- | IntrospectionEnumType
- | IntrospectionInputObjectType;
- export type IntrospectionOutputType =
- | IntrospectionScalarType
- | IntrospectionObjectType
- | IntrospectionInterfaceType
- | IntrospectionUnionType
- | IntrospectionEnumType;
- export type IntrospectionInputType =
- | IntrospectionScalarType
- | IntrospectionEnumType
- | IntrospectionInputObjectType;
- export type IntrospectionScalarType = {
- +kind: 'SCALAR',
- +name: string,
- +description?: ?string,
- ...
- };
- export type IntrospectionObjectType = {
- +kind: 'OBJECT',
- +name: string,
- +description?: ?string,
- +fields: $ReadOnlyArray<IntrospectionField>,
- +interfaces: $ReadOnlyArray<
- IntrospectionNamedTypeRef<IntrospectionInterfaceType>,
- >,
- ...
- };
- export type IntrospectionInterfaceType = {
- +kind: 'INTERFACE',
- +name: string,
- +description?: ?string,
- +fields: $ReadOnlyArray<IntrospectionField>,
- +possibleTypes: $ReadOnlyArray<
- IntrospectionNamedTypeRef<IntrospectionObjectType>,
- >,
- ...
- };
- export type IntrospectionUnionType = {
- +kind: 'UNION',
- +name: string,
- +description?: ?string,
- +possibleTypes: $ReadOnlyArray<
- IntrospectionNamedTypeRef<IntrospectionObjectType>,
- >,
- ...
- };
- export type IntrospectionEnumType = {
- +kind: 'ENUM',
- +name: string,
- +description?: ?string,
- +enumValues: $ReadOnlyArray<IntrospectionEnumValue>,
- ...
- };
- export type IntrospectionInputObjectType = {
- +kind: 'INPUT_OBJECT',
- +name: string,
- +description?: ?string,
- +inputFields: $ReadOnlyArray<IntrospectionInputValue>,
- ...
- };
- export type IntrospectionListTypeRef<
- T: IntrospectionTypeRef = IntrospectionTypeRef,
- > = {
- +kind: 'LIST',
- +ofType: T,
- ...
- };
- export type IntrospectionNonNullTypeRef<
- T: IntrospectionTypeRef = IntrospectionTypeRef,
- > = {
- +kind: 'NON_NULL',
- +ofType: T,
- ...
- };
- export type IntrospectionTypeRef =
- | IntrospectionNamedTypeRef<IntrospectionType>
- | IntrospectionListTypeRef<IntrospectionTypeRef>
- | IntrospectionNonNullTypeRef<
- | IntrospectionNamedTypeRef<IntrospectionType>
- | IntrospectionListTypeRef<IntrospectionTypeRef>,
- >;
- export type IntrospectionOutputTypeRef =
- | IntrospectionNamedTypeRef<IntrospectionOutputType>
- | IntrospectionListTypeRef<IntrospectionOutputTypeRef>
- | IntrospectionNonNullTypeRef<
- | IntrospectionNamedTypeRef<IntrospectionOutputType>
- | IntrospectionListTypeRef<IntrospectionOutputTypeRef>,
- >;
- export type IntrospectionInputTypeRef =
- | IntrospectionNamedTypeRef<IntrospectionInputType>
- | IntrospectionListTypeRef<IntrospectionInputTypeRef>
- | IntrospectionNonNullTypeRef<
- | IntrospectionNamedTypeRef<IntrospectionInputType>
- | IntrospectionListTypeRef<IntrospectionInputTypeRef>,
- >;
- export type IntrospectionNamedTypeRef<
- T: IntrospectionType = IntrospectionType,
- > = {
- +kind: $PropertyType<T, 'kind'>,
- +name: string,
- ...
- };
- export type IntrospectionField = {|
- +name: string,
- +description?: ?string,
- +args: $ReadOnlyArray<IntrospectionInputValue>,
- +type: IntrospectionOutputTypeRef,
- +isDeprecated: boolean,
- +deprecationReason: ?string,
- |};
- export type IntrospectionInputValue = {|
- +name: string,
- +description?: ?string,
- +type: IntrospectionInputTypeRef,
- +defaultValue: ?string,
- |};
- export type IntrospectionEnumValue = {|
- +name: string,
- +description?: ?string,
- +isDeprecated: boolean,
- +deprecationReason: ?string,
- |};
- export type IntrospectionDirective = {|
- +name: string,
- +description?: ?string,
- +locations: $ReadOnlyArray<DirectiveLocationEnum>,
- +args: $ReadOnlyArray<IntrospectionInputValue>,
- |};
|