-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: get TS function call type params working
- Loading branch information
1 parent
b912bc1
commit 708e6dc
Showing
2 changed files
with
96 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
76 changes: 76 additions & 0 deletions
76
test/graphql-typegen-async/ts/useMutationReplaceTypeParams.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
import * as path from 'path' | ||
|
||
export const file = 'file.tsx' | ||
export const normalize = false | ||
|
||
export const input = ` | ||
import * as React from 'react' | ||
import { useMutation } from '@apollo/react-hooks' | ||
import gql from 'graphql-tag' | ||
const mutation = gql\` | ||
mutation createReview($episode: Episode!, $review: ReviewInput!) { | ||
createReview(episode: $episode, review: $review) { | ||
episode | ||
stars | ||
commentary | ||
} | ||
} | ||
\` | ||
const Comp = (props: {id: string}): React.Node => { | ||
const [createReview] = useMutation<X>(mutation) | ||
return <div /> | ||
} | ||
` | ||
|
||
export const options = { | ||
addTypename: false, | ||
schemaFile: path.resolve(__dirname, '../../../starwars.graphql'), | ||
} | ||
|
||
export const expected = ` | ||
import * as React from 'react' | ||
import { useMutation } from '@apollo/react-hooks' | ||
import gql from 'graphql-tag' | ||
const mutation = gql\` | ||
mutation createReview($episode: Episode!, $review: ReviewInput!) { | ||
createReview(episode: $episode, review: $review) { | ||
episode | ||
stars | ||
commentary | ||
} | ||
} | ||
\` | ||
// @graphql-typegen auto-generated | ||
type CreateReviewMutationVariables = { | ||
episode: "NEWHOPE" | "EMPIRE" | "JEDI", | ||
review: { | ||
stars: number, | ||
commentary?: string | null, | ||
favorite_color?: { | ||
red: number, | ||
green: number, | ||
blue: number | ||
} | null | ||
} | ||
}; | ||
// @graphql-typegen auto-generated | ||
type CreateReviewMutationData = { | ||
createReview: { | ||
episode: "NEWHOPE" | "EMPIRE" | "JEDI" | null, | ||
stars: number, | ||
commentary: string | null | ||
} | null | ||
}; | ||
const Comp = (props: {id: string}): React.Node => { | ||
const [createReview] = useMutation<CreateReviewMutationData, CreateReviewMutationVariables>(mutation) | ||
return <div /> | ||
} | ||
` |