Skip to content

Commit cab01a0

Browse files
committed
test: make sure __typename doesn't get output for input types
1 parent 6ab1ced commit cab01a0

File tree

1 file changed

+82
-0
lines changed

1 file changed

+82
-0
lines changed
Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
import * as path from 'path'
2+
3+
export const file = 'file.js'
4+
5+
export const input = `
6+
// @flow
7+
import * as React from 'react'
8+
import { useMutation } from '@apollo/react-hooks'
9+
import gql from 'graphql-tag'
10+
11+
const mutation = gql\`
12+
mutation createReview($episode: Episode!, $review: ReviewInput!) {
13+
createReview(episode: $episode, review: $review) {
14+
episode
15+
stars
16+
commentary
17+
}
18+
}
19+
\`
20+
21+
const Comp = ({id: string}): React.Node => {
22+
const [createReview] = useMutation(mutation)
23+
return <div />
24+
}
25+
`
26+
27+
export const options = {
28+
schemaFile: path.resolve(__dirname, '../../starwars.graphql'),
29+
}
30+
31+
export const expected = `
32+
// @flow
33+
import * as React from 'react'
34+
import { useMutation, type MutationFunction } from '@apollo/react-hooks'
35+
import gql from 'graphql-tag'
36+
37+
const mutation = gql\`
38+
mutation createReview($episode: Episode!, $review: ReviewInput!) {
39+
createReview(episode: $episode, review: $review) {
40+
episode
41+
stars
42+
commentary
43+
}
44+
}
45+
\`
46+
47+
// @graphql-typegen auto-generated
48+
type CreateReviewMutationFunction = MutationFunction<
49+
CreateReviewMutationData,
50+
CreateReviewMutationVariables
51+
>
52+
53+
// @graphql-typegen auto-generated
54+
type CreateReviewMutationVariables = {
55+
episode: 'NEWHOPE' | 'EMPIRE' | 'JEDI',
56+
review: {
57+
stars: number,
58+
commentary?: ?string,
59+
favorite_color?: ?{
60+
red: number,
61+
green: number,
62+
blue: number,
63+
}
64+
}
65+
}
66+
67+
// @graphql-typegen auto-generated
68+
type CreateReviewMutationData = {
69+
__typename: 'Mutation',
70+
createReview: ?{
71+
__typename: 'Review',
72+
episode: ?('NEWHOPE' | 'EMPIRE' | 'JEDI'),
73+
stars: number,
74+
commentary: ?string,
75+
},
76+
}
77+
78+
const Comp = ({id: string}): React.Node => {
79+
const [createReview] = useMutation<CreateReviewMutationData, CreateReviewMutationVariables>(mutation)
80+
return <div />
81+
}
82+
`

0 commit comments

Comments
 (0)