question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

__typename is not added automatically after relay-compiler was removed

See original GitHub issue

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”

  • the data is coming from Contentful

Example code:

          if (component.__typename == 'CGQL_HeroCarousel') {
            return <HeroCarousel />;
          }

Example returned Json in 2.18.15:

{
sys: {id: "myId"}
name: "Component Name"
...
}

Example returned Json in 2.7.5:

{
__typename: "CGQL_HeroCarousel"
sys: {id: "myId"}
name: "Component Name"
....
}

“gatsby-node.js” has not changed, but included here for more information:

    {
      resolve: 'gatsby-source-graphql',
      options: {
        typeName: 'CGQL',
        fieldName: 'CGQL',
        url: getContentFulUrl(),
        headers: getContentFulHeader()
      }
    }

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:1
  • Comments:15 (10 by maintainers)

github_iconTop GitHub Comments

1reaction
NiviJahcommented, Dec 27, 2019

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.

0reactions
NiviJahcommented, Jan 23, 2020

Thank you @vladar for confirming that.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Inconsistent Typename Error - Relay
The most common reason for this error is that 2 objects backed by an ID are using the plain ID as the id...
Read more >
Codebase Health Considerations - RescriptRelay
RescriptRelay comes with a CLI that automates removing unused fields for you. Running yarn rescript-relay-cli remove-unused-fields will automatically remove ...
Read more >
Where art thou, my error? - Artsy Engineering
Possible solutions. Top-level GraphQL errors and treating an entire response as unusable when such errors exist. Some clients, such as Apollo ...
Read more >
Subscriptions and Live Queries - Real Time with GraphQL
When using an ORM such as Prisma, we can simply add a middleware for automatically invalidating resources.
Read more >
relay-compiler 0.0.0-main-d2388085 → 0.0.0-main-147ac300
package/relay-compiler.js CHANGED ... [t.loc]);return t},t.remove=function(e){return this. ... S(e):"Undefined Type Name"}function I(e,t,n,r,a,i){if(!e.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found