Skip to content
This repository has been archived by the owner on Apr 3, 2024. It is now read-only.

Separating queries and type defs with codegen #97

Open
jregistr opened this issue May 20, 2020 · 1 comment
Open

Separating queries and type defs with codegen #97

jregistr opened this issue May 20, 2020 · 1 comment

Comments

@jregistr
Copy link

Hello!
Using the gatsby-plugin-graphql-codegen plugin, is it possible to create separate files for types and queries?
Let's say I'd like all the types to be in a graphql-types.ts and graphql-queries.ts. In previous non gatsby projects using the codegen app standalone, I've done this using generates config. Something like this:

schema:
  - https://api.github...
generates:
  gql-types.ts:
    plugins:
      - typescript
  gql-queries.ts:
    documents:
      - 'src/**/*.ts'
    preset: import-types
    presetConfig:
      typesPath: ./gql-types
    plugins:
      - typescript-operations

I've tried adding an additionalSchema gatsby plugin option only pointing it to the tsx files. This doesn't seem to work.

Is this possible w/ the plugin as is?

@d4rekanguok
Copy link
Owner

Hi @jregistr! Thank you for your interest in this plugin.

It's not possible with the plugin as is, since we're not 1:1 map with codegen cli. For your use case, it might be simpler to write a script that utilize @graphql-codegen/cli directly, as shown here.

I'm thinking about using the cli as well, but haven't really make a decision yet.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants