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.

Cannot get type name from ThunkComposer

See original GitHub issue

Preliminary Checks

Description

I have enabled server-side rendering and DSG for our shop product pages. Page fetches the product review information in real-time using server-side rendering. After I enable server-side rendering, I am getting this error on build process.

Error: Cannot get type name from ThunkComposer({ _thunk: [function ], _typeName: "ContentBlock" })

This ContentBlock is a custom schema interface that I created using the createSchemaCustomization API.

FYI, it’s working fine on development mode.

Reproduction Link

Minimal Reproduction Repository

Steps to Reproduce

  1. Run gatsby build

Expected Result

Build should be done without any problems

Actual Result

3:19:48 PM: error /opt/build/repo/.cache/query-engine/index.js:130612
3:19:48 PM:       throw new Error(`Cannot get type name from ${(0,_misc__WEBPACK_IMPORTED_MODULE_2__.inspect)(type)}`);
3:19:48 PM:             ^
3:19:48 PM: error Error: Cannot get type name from ThunkComposer({ _thunk: [function ], _typeName: "ContentBlock" })
3:19:48 PM:     at getComposeTypeName (/opt/build/repo/.cache/query-engine/index.js:130612:13)
3:19:48 PM:     at ObjectTypeComposer.hasInterface (/opt/build/repo/.cache/query-engine/index.js:126738:93)
3:19:48 PM:     at ObjectTypeComposer.addInterface (/opt/build/repo/.cache/query-engine/index.js:126743:15)
3:19:48 PM:     at /opt/build/repo/.cache/query-engine/index.js:206241:56
3:19:48 PM:     at Array.forEach (<anonymous>)
3:19:48 PM:     at mergeTypes (/opt/build/repo/.cache/query-engine/index.js:206241:26)
3:19:48 PM:     at /opt/build/repo/.cache/query-engine/index.js:207100:7
3:19:48 PM:     at Array.forEach (<anonymous>)
3:19:48 PM:     at parseTypes (/opt/build/repo/.cache/query-engine/index.js:207086:19)
3:19:48 PM:     at /opt/build/repo/.cache/query-engine/index.js:206133:23
3:19:48 PM:     at Array.forEach (<anonymous>)
3:19:48 PM:     at addTypes (/opt/build/repo/.cache/query-engine/index.js:206120:9)
3:19:48 PM:     at updateSchemaComposer (/opt/build/repo/.cache/query-engine/index.js:205982:9)
3:19:48 PM:     at buildSchema (/opt/build/repo/.cache/query-engine/index.js:205925:9)
3:19:48 PM:     at build (/opt/build/repo/.cache/query-engine/index.js:24422:18)
3:19:48 PM:     at GraphQLEngine._doGetRunner (/opt/build/repo/.cache/query-engine/index.js:448573:5)

Environment

System:
  OS: Windows 11
Binaries
  Node: v16.3.0
  NPM: v7.15.1
Gatsby: v4.1.4

Config Flags

No response

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:1
  • Comments:14 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
marcomiduricommented, Nov 22, 2021

@LekoArts @graysonhicks Thanks for your immediate response. I just removed schema.graphql file and moved the graphql code into gatsby-node.js. Please check my last commit. But it’s the same…

1reaction
LekoArtscommented, Nov 22, 2021

You can’t do this with engines as it doesn’t support bundling these files:

https://github.com/marcomiduri/gatsby-issue-reproduction/blob/50bbe785b4abcd0e92f82a4e16f0b1ee3b255295/gatsby-node.js#L17-L20

You’ll need to put the definition either in a JS file and import it or directly put it into gatsby-node.js

(So this is not a bug but a limitation)

Read more comments on GitHub >

github_iconTop Results From Across the Web

Type with name "AuthorYaml" does not exists - gatsby-casper ...
So if you haven't defined that node, your GraphQL query is not able to run, hence the code is breaking. Pulling more the...
Read more >
InterfaceTypeComposer - graphql-compose
Remove fields from type by name or array of names. ... Automatically unwrap from List, NonNull, ThunkComposer It's important! ... getTypeName(): string ...
Read more >
graphql-compose - UNPKG
54, const typeName = typeDef; ... + 'Eg. `type MyType { name: String }`'); ... 144, throw new Error(`Cannot get field '${fieldName}' from...
Read more >
cannot query field on type query - You.com | The AI Search ...
... objects: myBasicQuery: [BasicAnswer] type BasicAnswer { name String phone String } I was getting the error: Cannot query field \"BasicAnswer\" on type...
Read more >
GraphQL error handling to the max with Typescript, codegen ...
You'll get a 5xx error in case the server is not available at all. ... Type-safety: the errors are also typed; The consumer...
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