/** * Copyright (c) Facebook, Inc. and its affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * * @flow strict * @format */ // flowlint ambiguous-object-type:error 'use strict'; import type { LinkedFieldTypeID, ScalarFieldTypeID, CompositeTypeID, InputTypeID, } from './Schema'; import type {Source} from 'graphql'; export type Metadata = ?{[key: string]: mixed, ...}; export type SourceLocation = {| +kind: 'Source', +start: number, +end: number, +source: Source, |}; export type GeneratedLocation = {| +kind: 'Generated', |}; export type DerivedLocation = {| +kind: 'Derived', +source: Location, |}; export type UnknownLocation = {|+kind: 'Unknown'|}; export type Location = | SourceLocation | GeneratedLocation | DerivedLocation | UnknownLocation; export type Argument = {| +kind: 'Argument', +loc: Location, +name: string, +type: ?InputTypeID, +value: ArgumentValue, |}; export type ArgumentDefinition = | LocalArgumentDefinition | RootArgumentDefinition; export type ArgumentValue = ListValue | Literal | ObjectValue | Variable; export type Condition = {| +kind: 'Condition', +condition: Literal | Variable, +loc: Location, +passingValue: boolean, +selections: $ReadOnlyArray, |}; export type Directive = {| +args: $ReadOnlyArray, +kind: 'Directive', +loc: Location, +name: string, |}; export type Field = LinkedField | ScalarField; export type Fragment = {| +argumentDefinitions: $ReadOnlyArray, +directives: $ReadOnlyArray, +kind: 'Fragment', +loc: Location, +metadata: Metadata, +name: string, +selections: $ReadOnlyArray, +type: CompositeTypeID, |}; export type FragmentSpread = {| +args: $ReadOnlyArray, +directives: $ReadOnlyArray, +kind: 'FragmentSpread', +loc: Location, +metadata: Metadata, +name: string, |}; export type Defer = {| +kind: 'Defer', +loc: Location, +selections: $ReadOnlyArray, +label: string, +if: ArgumentValue | null, |}; export type Stream = {| +kind: 'Stream', +loc: Location, +metadata: Metadata, +selections: $ReadOnlyArray, +label: string, +if: ArgumentValue | null, +initialCount: ArgumentValue, +useCustomizedBatch: ArgumentValue | null, |}; export type InlineDataFragmentSpread = {| +kind: 'InlineDataFragmentSpread', +loc: Location, +metadata: Metadata, +name: string, +selections: $ReadOnlyArray, |}; export type IR = | Argument | ClientExtension | Condition | Defer | Directive | Fragment | FragmentSpread | InlineDataFragmentSpread | InlineFragment | LinkedField | ListValue | Literal | LocalArgumentDefinition | ModuleImport | ObjectFieldValue | ObjectValue | Request | Root | RootArgumentDefinition | ScalarField | SplitOperation | Stream | Variable; export type ObjectFieldValue = {| +kind: 'ObjectFieldValue', +loc: Location, +name: string, +value: ArgumentValue, |}; export type ObjectValue = {| +kind: 'ObjectValue', +fields: $ReadOnlyArray, +loc: Location, |}; export type RootArgumentDefinition = {| +kind: 'RootArgumentDefinition', +loc: Location, +name: string, +type: InputTypeID, |}; export type InlineFragment = {| +directives: $ReadOnlyArray, +kind: 'InlineFragment', +loc: Location, +metadata: Metadata, +selections: $ReadOnlyArray, +typeCondition: CompositeTypeID, |}; export type Handle = {| +name: string, +key: string, +dynamicKey: Variable | null, +filters: ?$ReadOnlyArray, +handleArgs?: $ReadOnlyArray, |}; export type ClientExtension = {| +kind: 'ClientExtension', +loc: Location, +metadata: Metadata, +selections: $ReadOnlyArray, |}; export type LinkedField = {| +alias: string, +args: $ReadOnlyArray, +connection: boolean, +directives: $ReadOnlyArray, +handles: ?$ReadOnlyArray, +kind: 'LinkedField', +loc: Location, +metadata: Metadata, +name: string, +selections: $ReadOnlyArray, +type: LinkedFieldTypeID, |}; export type ListValue = {| +kind: 'ListValue', +items: $ReadOnlyArray, +loc: Location, |}; export type Literal = {| +kind: 'Literal', +loc: Location, +value: mixed, |}; export type LocalArgumentDefinition = {| +defaultValue: mixed, +kind: 'LocalArgumentDefinition', +loc: Location, +name: string, +type: InputTypeID, |}; export type ModuleImport = {| +kind: 'ModuleImport', +loc: Location, // a key used as part of the storage key for fields relating to this @module // instance. by default the key is the name of the document where the @module // was defined, but can be overridden with the 'key' argument. +key: string, // the name of the document where the module was defined, used for attributing // the generated SplitOperations to the module that caused their creation. +sourceDocument: string, // the name of the module to require +module: string, // a value that uniquely identifies this @module position in the codebase: // the documentName plus the relative field path of the @module within that // document +id: string, // the name of the original FragmentSpread on which @module was applied +name: string, +selections: $ReadOnlyArray, |}; export type Node = | ClientExtension | Condition | Defer | Fragment | InlineDataFragmentSpread | InlineFragment | LinkedField | ModuleImport | Root | SplitOperation | Stream; export type Request = {| +kind: 'Request', +fragment: Fragment, +id: ?string, +loc: Location, +metadata: Metadata, +name: string, +root: Root, +text: ?string, |}; export type Root = {| +argumentDefinitions: $ReadOnlyArray, +directives: $ReadOnlyArray, +kind: 'Root', +loc: Location, +metadata: Metadata, +name: string, +operation: 'query' | 'mutation' | 'subscription', +selections: $ReadOnlyArray, +type: CompositeTypeID, |}; export type ScalarField = {| +alias: string, +args: $ReadOnlyArray, +directives: $ReadOnlyArray, +handles: ?$ReadOnlyArray, +kind: 'ScalarField', +loc: Location, +metadata: Metadata, +name: string, +type: ScalarFieldTypeID, |}; export type Selection = | ClientExtension | Condition | Defer | FragmentSpread | InlineDataFragmentSpread | InlineFragment | LinkedField | ModuleImport | ScalarField | Stream; export type Definition = Fragment | Root | SplitOperation; export type GeneratedDefinition = Fragment | Request | SplitOperation; export type SplitOperation = {| +kind: 'SplitOperation', +name: string, +selections: $ReadOnlyArray, +loc: Location, +metadata: Metadata, +parentSources: Set, +type: CompositeTypeID, |}; export type Variable = {| +kind: 'Variable', +loc: Location, +variableName: string, +type: ?InputTypeID, |};