Skip to content

Commit 93f5f85

Browse files
committed
fix: don't extract field types of extract input types
1 parent 3c37706 commit 93f5f85

File tree

3 files changed

+59
-1
lines changed

3 files changed

+59
-1
lines changed

src/internal/generateFlowTypesFromDocument.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -979,8 +979,9 @@ export default function generateFlowTypesFromDocument({
979979
config: ConfigDirectives
980980
): FlowTypeKind {
981981
config = getCombinedConfig(type.config, config)
982+
const fieldConfig = { ...config, extract: undefined }
982983
return objectTypeAnnotation(
983-
map(type.inputFields, field => convertInputField(field, config)),
984+
map(type.inputFields, field => convertInputField(field, fieldConfig)),
984985
config
985986
)
986987
}

starwars.graphql

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ type Query {
2222
# The mutation type, represents all updates we can make to our data
2323
type Mutation {
2424
createReview(episode: Episode, review: ReviewInput!): Review
25+
testExtractInput(input: TestExtractInput!): Boolean
2526
}
2627
# The subscription type, represents all subscriptions we can make to our data
2728
type Subscription {
@@ -151,3 +152,12 @@ type Starship {
151152
coordinates: [[Float!]!]
152153
}
153154
union SearchResult = Human | Droid | Starship
155+
156+
scalar JSON
157+
158+
input TestExtractInput {
159+
foo: String!
160+
bar: Int!
161+
date: Date
162+
json: JSON
163+
}
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
import * as path from 'path'
2+
3+
export const file = 'file.js'
4+
5+
export const input = `
6+
// @flow
7+
import gql from 'graphql-tag'
8+
9+
const mutation = gql\`
10+
mutation testExtractInput(
11+
# @graphql-typegen extract
12+
$input: TestExtractInput!
13+
) {
14+
testExtractInput(input: $input)
15+
}
16+
\`
17+
`
18+
19+
export const options = {
20+
addTypename: false,
21+
schemaFile: path.resolve(__dirname, '../../starwars.graphql'),
22+
}
23+
24+
export const expected = `
25+
// @flow
26+
import gql from 'graphql-tag'
27+
import { type DateISOString } from '../../src/DateISOString'
28+
const mutation = gql\`
29+
mutation testExtractInput(
30+
# @graphql-typegen extract
31+
$input: TestExtractInput!
32+
) {
33+
testExtractInput(input: $input)
34+
}
35+
\`
36+
// @graphql-typegen auto-generated
37+
type TestExtractInputMutationVariables = { input: TestExtractInput }
38+
// @graphql-typegen auto-generated
39+
type TestExtractInput = {
40+
foo: string,
41+
bar: number,
42+
date?: ?DateISOString,
43+
json?: ?mixed,
44+
}
45+
// @graphql-typegen auto-generated
46+
type TestExtractInputMutationData = { testExtractInput: ?boolean }
47+
`

0 commit comments

Comments
 (0)