The query is always of type unknown when created with @graphql-codegen #8485
Answered
by
charlypoly
perevezencev
asked this question in
Q&A
-
I have a this graphql query: import { graphql } from '../__generated__/gql';
// typeof IndexPageQuery is unknown
const IndexPageQuery = graphql(`
query IndexPageQuery {
user {
...UserInputFragment
}
}
${UserInputFragment}
`); And when i run this code: const { data } = await apolloClient.query(IndexPageQuery); TS throw error:
Why |
Beta Was this translation helpful? Give feedback.
Answered by
charlypoly
Oct 21, 2022
Replies: 1 comment
-
Hi, Including the fragment definition in the GraphQL operation definition is no longer necessary when using the Please remove the const IndexPageQuery = graphql(`
query IndexPageQuery {
user {
...UserInputFragment
}
}
`); Then, your query should be typed properly! |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
charlypoly
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi,
Including the fragment definition in the GraphQL operation definition is no longer necessary when using the
preset: "client"
.Please remove the
${UserInputFragment}
line as follows:Then, your query should be typed properly!