-
Notifications
You must be signed in to change notification settings - Fork 10.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
__typename is not added automatically after relay-compiler was removed #20290
Comments
I am not sure if this is related to the use of graphql-tools-fork by #20042 You should still be able to access __typename, but you should have to specify the __typename field in the query. I believe you are probably specifying the field already in the query? A minimal reproduction might be helpful, I would be happy to look into it. |
Looks like
|
Order changes because chaining transforms now works with multiple transformResult, so check result goes first, because result transforms processed in reverse order, should not matter here. |
Is it strange that the typename is not null? Almost as if it is being stripped from the outer query? |
I am able to modify example using-gatsby-source-graphql to retrieve typename of interface:
` |
Hi @NiviJah! It would be incredibly helpful if you could create a minimal reproduction. This is a simplified example of the issue that makes it clear and obvious what the issue is and how we can debug it. |
Sure thing, I was following the thread but I'm away of my computer for the holidays. I will do my best replicating this and will update. |
Why don't you post the part where you construct the query (until you can get a full working repo)? |
Relevant pieces of code:Page(template) level GQL Query
DynamicPageFragment:
PanelFragment - this is where the __typename was added
|
Above is where I would put __typename. If you can get a full reproducing example I can take a closer look of course. |
Yes, I can confirm that fixes the issue. in contentful, the "DynamicPage" content type, contains multiple items, "Panel" is one of those. there are two issues solved by specifying __typename on DynamicPage
This worked "automatically" in older versions, but as to 2.18.x this has to be declared manually DynamicPageFragment ( "parent container"):
PanelFragment (component):
|
Oh, this is probably unrelated to Basically relay compiler was adding
We should fix this in the core as this was a breaking change. |
Thank you @vladar for confirming that. |
Summary
I am using an if statement to determine the type of the GQL fragment, and render the right component accordingly.
This was working well in gatsby 2.7.5, but this field no longer exists after upgrading Gatsby to 2.18.15
"gatsby-source-graphql": "^2.1.29"
Example code:
Example returned Json in 2.18.15:
Example returned Json in 2.7.5:
"gatsby-node.js" has not changed, but included here for more information:
The text was updated successfully, but these errors were encountered: