<commit_before>import type { DirectiveLocationEnum } from '../language/directiveLocation';

export type IntrospectionOptions = {|
  // Whether to include descriptions in the introspection result.
  // Default: true
  descriptions?: boolean,

  // Whether to include `specifiedByUrl` in the introspection result.
  // Default: false
  specifiedByUrl?: boolean,

  // Whether to include `isRepeatable` field on directives.
  // Default: false
  directiveIsRepeatable?: boolean,

  // Whether to include `description` field on schema.
  // Default: false
  schemaDescription?: boolean,
|};

export function getIntrospectionQuery(options?: IntrospectionOptions): string {
  const optionsWithDefault = {
    descriptions: true,
    specifiedByUrl: false,
    directiveIsRepeatable: false,
    schemaDescription: false,
    ...options,
  };

  const descriptions = optionsWithDefault.descriptions ? 'description' : '';
  const specifiedByUrl = optionsWithDefault.specifiedByUrl
    ? 'specifiedByUrl'
    : '';
  const directiveIsRepeatable = optionsWithDefault.directiveIsRepeatable
    ? 'isRepeatable'
    : '';
  const schemaDescription = optionsWithDefault.schemaDescription
    ? descriptions
    : '';

  return `
    query IntrospectionQuery {
      __schema {
        ${schemaDescription}
        queryType { name }
        mutationType { name }
        subscriptionType { name }
        types {
          ...FullType
        }
        directives {
          name
          ${descriptions}
          ${directiveIsRepeatable}
          locations
          args {
            ...InputValue
          }
        }
      }
    }

    fragment FullType on __Type {
      kind
      name
      ${descriptions}
      ${specifiedByUrl}
      fields(includeDeprecated: true) {
        name
        ${descriptions}
        args {
          ...InputValue
        }
        type {
          ...TypeRef
        }
        isDeprecated
        deprecationReason
      }
      inputFields {
        ...InputValue
      }
      interfaces {
        ...TypeRef
      }
      enumValues(includeDeprecated: true) {
        name
        ${descriptions}
        isDeprecated
        deprecationReason
      }
      possibleTypes {
        ...TypeRef
      }
    }

    fragment InputValue on __InputValue {
      name
      ${descriptions}
      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
                  }
                }
              }
            }
          }
        }
      }
    }
  `;
}

export type IntrospectionQuery = {|
  +__schema: IntrospectionSchema,
|};

export type IntrospectionSchema = {|
  +description?: ?string,
  +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,
  +specifiedByUrl: ?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>,
  +interfaces: $ReadOnlyArray<
    IntrospectionNamedTypeRef<IntrospectionInterfaceType>,
  >,
  +possibleTypes: $ReadOnlyArray<
    IntrospectionNamedTypeRef<IntrospectionObjectType>,
  >,
|};

export type IntrospectionUnionType = {|
  +kind: 'UNION',
  +name: string,
  +description?: ?string,
  +possibleTypes: $ReadOnlyArray<<commit_msg>Make specifiedByUrl in IntrospectionScalarType's flow type optional (#2788)<commit_after>import type { DirectiveLocationEnum } from '../language/directiveLocation';

export type IntrospectionOptions = {|
  // Whether to include descriptions in the introspection result.
  // Default: true
  descriptions?: boolean,

  // Whether to include `specifiedByUrl` in the introspection result.
  // Default: false
  specifiedByUrl?: boolean,

  // Whether to include `isRepeatable` field on directives.
  // Default: false
  directiveIsRepeatable?: boolean,

  // Whether to include `description` field on schema.
  // Default: false
  schemaDescription?: boolean,
|};

export function getIntrospectionQuery(options?: IntrospectionOptions): string {
  const optionsWithDefault = {
    descriptions: true,
    specifiedByUrl: false,
    directiveIsRepeatable: false,
    schemaDescription: false,
    ...options,
  };

  const descriptions = optionsWithDefault.descriptions ? 'description' : '';
  const specifiedByUrl = optionsWithDefault.specifiedByUrl
    ? 'specifiedByUrl'
    : '';
  const directiveIsRepeatable = optionsWithDefault.directiveIsRepeatable
    ? 'isRepeatable'
    : '';
  const schemaDescription = optionsWithDefault.schemaDescription
    ? descriptions
    : '';

  return `
    query IntrospectionQuery {
      __schema {
        ${schemaDescription}
        queryType { name }
        mutationType { name }
        subscriptionType { name }
        types {
          ...FullType
        }
        directives {
          name
          ${descriptions}
          ${directiveIsRepeatable}
          locations
          args {
            ...InputValue
          }
        }
      }
    }

    fragment FullType on __Type {
      kind
      name
      ${descriptions}
      ${specifiedByUrl}
      fields(includeDeprecated: true) {
        name
        ${descriptions}
        args {
          ...InputValue
        }
        type {
          ...TypeRef
        }
        isDeprecated
        deprecationReason
      }
      inputFields {
        ...InputValue
      }
      interfaces {
        ...TypeRef
      }
      enumValues(includeDeprecated: true) {
        name
        ${descriptions}
        isDeprecated
        deprecationReason
      }
      possibleTypes {
        ...TypeRef
      }
    }

    fragment InputValue on __InputValue {
      name
      ${descriptions}
      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
                  }
                }
              }
            }
          }
        }
      }
    }
  `;
}

export type IntrospectionQuery = {|
  +__schema: IntrospectionSchema,
|};

export type IntrospectionSchema = {|
  +description?: ?string,
  +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,
  +specifiedByUrl?: ?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>,
  +interfaces: $ReadOnlyArray<
    IntrospectionNamedTypeRef<IntrospectionInterfaceType>,
  >,
  +possibleTypes: $ReadOnlyArray<
    IntrospectionNamedTypeRef<IntrospectionObjectType>,
  >,
|};

export type IntrospectionUnionType = {|
  +kind: 'UNION',
  +name: string,
  +description?: ?string,
  +possibleTypes: $ReadOnlyArray<
{'fraction_non_alphanumeric': 0.08639420589756855, 'fraction_numerical': 0.0004138644593895499, 'mean_word_length': 2.296725784447476, 'pattern_counts': {'":': 0, '<': 31, '<?xml version=': 0, '>': 29, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6631695', 'n_tokens_mistral': 2695, 'n_tokens_neox': 2649, 'n_words': 542}