Use Case
There are a number of ways we could leverage gatsby features like graphqlTypegen, the gatsby node APIs, graphql files (.gql) to make development in this framework easier and more typesafe.
I think we can avoid runtime bugs.
Gatsby can autogenerate very exact typing for the schema created in its APIs like createSchemaCustomization, createResolvers etc.
The scope of addressing this could vary but I see these as possible subtasks:
- configure
gatsby to use graphqlTypegen: true, generate and commit the types file
- refactor one (or more) files to use the generated types in place of manual typing
- adjust and update schema customization to fit this more precise typing
- migrate some (or all) of the string literal in
createSchemaCustomization to .gql files to leverage IDE support in writing schemas
- use resolvers for new schema in place of downstream data unpacking functions to ensure fields are present and populated according to various logic
- install
vitest and write test suites for resolvers (important especially if resolvers are untyped/raw javascript)
- stretch: consider TS migration for aspects of gatsby config
In general I think this will be a good modernizing push and will make for a smoother dev experience and less runtime weirdness.
I started working on this while trying to address Issue #7 but frankly it's a big topic and not worth serving as a roadblock to small front end features.
That said, refactoring takes more time the larger a codebase gets so I'd rather work on this sooner than later.
Acceptance Criteria
Please describe how you know this is done
Details
Please provide any helpful specifications
Use Case
There are a number of ways we could leverage gatsby features like
graphqlTypegen, the gatsby node APIs, graphql files (.gql) to make development in this framework easier and more typesafe.I think we can avoid runtime bugs.
Gatsby can autogenerate very exact typing for the schema created in its APIs like
createSchemaCustomization,createResolversetc.The scope of addressing this could vary but I see these as possible subtasks:
gatsbyto usegraphqlTypegen: true, generate and commit the types filecreateSchemaCustomizationto.gqlfiles to leverage IDE support in writing schemasvitestand write test suites for resolvers (important especially if resolvers are untyped/raw javascript)In general I think this will be a good modernizing push and will make for a smoother dev experience and less runtime weirdness.
I started working on this while trying to address Issue #7 but frankly it's a big topic and not worth serving as a roadblock to small front end features.
That said, refactoring takes more time the larger a codebase gets so I'd rather work on this sooner than later.
Acceptance Criteria
Please describe how you know this is done
Details
Please provide any helpful specifications