Skip to content

Commit

Permalink
fix: don't extract field types of extract input types
Browse files Browse the repository at this point in the history
  • Loading branch information
jedwards1211 committed Aug 30, 2020
1 parent 3c37706 commit 93f5f85
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/internal/generateFlowTypesFromDocument.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
)
}
Expand Down
10 changes: 10 additions & 0 deletions starwars.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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
}
47 changes: 47 additions & 0 deletions test/graphql-typegen-async/mutationExtractInput.ts
Original file line number Diff line number Diff line change
@@ -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 }
`

0 comments on commit 93f5f85

Please sign in to comment.