![]() New fields will not be available on filter and sort input types.Possible, overriding field types is allowed. In case of types added from third-party schemas, where this is not Overriding field types is disallowed, instead use the createTypesĪction.createPages = ( Īdd custom field resolvers to the GraphQL schema.Īllows adding new fields to types by providing field configs, or adding resolver If your plugin does not do async work, you can return directly.Įxports. See Debugging Async Lifecycles for more info. Gatsby needs to know when plugins are finished as some APIs, to work correctly, require previous APIs to be complete first. If your plugin performs async operations (disk I/O, database access, calling remote APIs, etc.) you must either return a promise (explicitly using Promise API or implicitly using async/ await syntax) or use the callback passed to the 3rd argument. Read the ES Modules (ESM) and Gatsby documentation if you don’t want to use CommonJS syntax. The TypeScript and Gatsby documentation shows how to set up a gatsby-node file in TypeScript. These let you access several methods like reporting, or perform actions like creating new pages.Īn example gatsby-node.js file that implements two APIs, onPostBuild, and createPages. You can author the file in JavaScript (CommonJS or ES Modules (ESM) syntax) or TypeScript.Įvery Gatsby Node API gets passed a set of helper functions. Export any of the APIs you wish to use in this file. ![]() To use the Gatsby Node APIs, create a file named gatsby-node.js/ gatsby-node.ts in the root of your site. You can use its APIs to create pages dynamically, add data into GraphQL, or respond to events during the build lifecycle. Code in the file gatsby-node.js/ gatsby-node.ts is run once in the process of building your site. ![]() Gatsby gives plugins and site builders many APIs for building your site.
0 Comments
Leave a Reply. |