diff --git a/src/internal/generateFlowTypesFromDocument.ts b/src/internal/generateFlowTypesFromDocument.ts index 031df94..c4921b1 100644 --- a/src/internal/generateFlowTypesFromDocument.ts +++ b/src/internal/generateFlowTypesFromDocument.ts @@ -979,8 +979,9 @@ export default function generateFlowTypesFromDocument({ config: ConfigDirectives ): FlowTypeKind { config = getCombinedConfig(type.config, config) + const fieldConfig = { ...config, extract: undefined } return objectTypeAnnotation( - map(type.inputFields, field => convertInputField(field, config)), + map(type.inputFields, field => convertInputField(field, fieldConfig)), config ) } diff --git a/starwars.graphql b/starwars.graphql index f567197..8bb9366 100644 --- a/starwars.graphql +++ b/starwars.graphql @@ -22,6 +22,7 @@ type Query { # The mutation type, represents all updates we can make to our data type Mutation { createReview(episode: Episode, review: ReviewInput!): Review + testExtractInput(input: TestExtractInput!): Boolean } # The subscription type, represents all subscriptions we can make to our data type Subscription { @@ -151,3 +152,12 @@ type Starship { coordinates: [[Float!]!] } union SearchResult = Human | Droid | Starship + +scalar JSON + +input TestExtractInput { + foo: String! + bar: Int! + date: Date + json: JSON +} diff --git a/test/graphql-typegen-async/mutationExtractInput.ts b/test/graphql-typegen-async/mutationExtractInput.ts new file mode 100644 index 0000000..3f2027e --- /dev/null +++ b/test/graphql-typegen-async/mutationExtractInput.ts @@ -0,0 +1,47 @@ +import * as path from 'path' + +export const file = 'file.js' + +export const input = ` +// @flow +import gql from 'graphql-tag' + +const mutation = gql\` +mutation testExtractInput( + # @graphql-typegen extract + $input: TestExtractInput! +) { + testExtractInput(input: $input) +} +\` +` + +export const options = { + addTypename: false, + schemaFile: path.resolve(__dirname, '../../starwars.graphql'), +} + +export const expected = ` +// @flow +import gql from 'graphql-tag' +import { type DateISOString } from '../../src/DateISOString' +const mutation = gql\` +mutation testExtractInput( + # @graphql-typegen extract + $input: TestExtractInput! +) { + testExtractInput(input: $input) +} +\` +// @graphql-typegen auto-generated +type TestExtractInputMutationVariables = { input: TestExtractInput } +// @graphql-typegen auto-generated +type TestExtractInput = { + foo: string, + bar: number, + date?: ?DateISOString, + json?: ?mixed, +} +// @graphql-typegen auto-generated +type TestExtractInputMutationData = { testExtractInput: ?boolean } +`