Issue with GraphQL fragment composition in retrieving fields when spreading fragments on a type that is implemented by other types. #9548
Unanswered
vandercloak
asked this question in
Q&A
Replies: 2 comments
-
Oh, almost forgot. Here are the package versions I am using (Everything should be latest as of the day of posting): "@graphql-codegen/cli": "^4.0.1",
"@graphql-codegen/fragment-matcher": "^5.0.0",
"@graphql-codegen/typescript": "^4.0.1",
"@graphql-codegen/typescript-operations": "^4.0.1",
"@graphql-codegen/typescript-react-apollo": "^3.3.7", |
Beta Was this translation helpful? Give feedback.
0 replies
-
same issue here i think const getSpendLimitQuery = gql(`
query SpendingLimit {
user {
... on User {
...SpendingFragment
}
}
}`) and the type generated are missing the spending limit, no matter what i add in when i look at the type it seems to be there but not properly type i'm guessing my codegen.ts import type { CodegenConfig } from "@graphql-codegen/cli"
const config: CodegenConfig = {
overwrite: true,
schema: process.env.GRAPHQL_API,
documents: ["src/**/*.tsx", "app/**/*.tsx", "src/**/*.ts"],
ignoreNoDocuments: true,
generates: {
"src/__generated__/": {
preset: "client",
plugins: [],
presetConfig: {
gqlTagName: "gql",
},
},
},
}
export default config deps:
i think the main difference is that my graphql response from urql has the data of spending limit, just missing the types. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I'm facing an issue with GraphQL fragment composition when attempting to retrieve specific fields from the Slide and Element types. The problem arises when including fields from the Element type within the Slide type using fragment composition.
I am using Slide + Element for context to describe this issue, but I have encountered this in other fragment spreading attempts.
Here is the GraphQL schema for Slide:
And here is the GraphQL schema for Element/ElementText:
Now, let's consider the following fragments. First, here's an example of the Fragment structure that does not work as I expected to:
This results in a json response of:
This response is incomplete and DOES NOT contain all the fields I expected it to.
Second, here's an example of the query that does work as expected (but is not desired):
This results in the correct json response of:
The second option works and is what I will be using until I find a solution. But its a pain for reusability and is honestly just puzzling to me. I am really curious to know how I am thinking about fragments incorrectly, or alternatively, if there is an issue/bug to bring it to light.
Thanks for any feedback! and if you made it this far 🤜🤛
Beta Was this translation helpful? Give feedback.
All reactions