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.

Types for gatsby-node.ts

See original GitHub issue

Hi, I’m trying to get types generated for my root query in gatsby-node.ts.

Somehow this seems to not work. I used a query name (e.g. query GatsbyNode ...) as with all my other queries. All other type generation works fine, just not the gatsby-node.ts ones.

What am I doing wrong here

Issue Analytics

  • State:open
  • Created 3 years ago
  • Reactions:2
  • Comments:8 (2 by maintainers)

github_iconTop GitHub Comments

6reactions
LekoArtscommented, Apr 25, 2022

As part of this RFC/Initiative https://github.com/gatsbyjs/gatsby/discussions/35420 I have a WIP PR up for an initial implementation. I have support for gatsby-node.ts working. I’d be really happy if you could follow that discussion and once I have a version published to try out, you could try it out. Thanks!

0reactions
knpwrscommented, Mar 7, 2022

As a temporary workaround I added the following codegen.yml to my project:

schema: http://localhost:8000/__graphql
documents:
  - ./gatsby-node.ts
generates:
  ./src/__generated__/gatsby-node-types.ts:
    plugins:
      - typescript
      - typescript-operations

Then I run a generate script defined as such:

"scripts": {
  "generate": "graphql-codegen",
}

This makes the type generation for the gatsby-*.ts files out-of-band, but it works for me for root queries until this plugin supports gatsby-node.ts.

Read more comments on GitHub >

github_iconTop Results From Across the Web

TypeScript and Gatsby
Read the Gatsby Config API documentation to learn more about its different options. gatsby-node.ts. Support added in gatsby@4.9.0. You can import ...
Read more >
TypeScript + Gatsby config and node API - gists · GitHub
js. // Use the type definitions that are included with Gatsby. import { GatsbyNode } from "gatsby"; import { resolve } from "path";...
Read more >
How to use Gatsby with Typescript. - DEV Community ‍ ‍
Its really useful to install types for react, react-dom, ... src/app/GatsbyNode.ts , but you have to make sure you export the functions with ......
Read more >
Gatsby config with TypeScript - miyauci.me
gatsby-config.ts. ├── gatsby-node.js. └── gatsby-ssr.js. bash. From now on, we will configure gatsby-config.ts with types. It will look like this:.
Read more >
How To Set Up a Gatsby Project with TypeScript - DigitalOcean
Head over to your preferred browser and type ... This includes gatsby-node.js , gatsby-browser.js , and gatsby-ssr.js : rm gatsby-node.js ...
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