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

[codegen] Make additionalSchemas configuration easier #80

Open
d4rekanguok opened this issue Mar 27, 2020 · 0 comments
Open

[codegen] Make additionalSchemas configuration easier #80

d4rekanguok opened this issue Mar 27, 2020 · 0 comments
Labels
enhancement New feature or request help wanted Extra attention is needed

Comments

@d4rekanguok
Copy link
Owner

d4rekanguok commented Mar 27, 2020

Current minimal setup:

exports.default = {
  plugins: [{
    resolve: `gatsby-plugin-graphql-codegen`,
    options: {
      // (1)
      additionalSchemas: [{
        // (2)
        key: 'pokemon',
        // (3)
        fileName: './graphql-pokemon.ts',
        schema: 'https://graphql-pokemon.now.sh/',
        // (4)
        pluckConfig: {  //
          // config to ensure only queries using the `gql` tag are used for this schema
          globalGqlIdentifierName: 'gql',
          modules: [
            {
              name: 'graphql-tag',
              identifier: 'gql',
            },
          ],
        },
      }],
    }
  }]
}

Considering that most users would have only 1 additional schema, we should:

  1. Check if additionalSchemas is an array or object, so user can just pass in an object directly
  2. Remove key. Make key optional. Create a key automatically based on schema path
  3. Make fileName optional. Use a sensible default like graphql-types-addition, if additionalSchemas is an array, append a number
  4. Make pluckConfig optional. User only needs to pass in name & identifier

So ideally, most users should only need to do this:

exports.default = {
  plugins: [{
    resolve: `gatsby-plugin-graphql-codegen`,
    options: {
      additionalSchemas: {
        schema: 'https://graphql-pokemon.now.sh/',
        //  import gql from 'graphql-tag'
        gqlIdentifier: ['gql', 'graphql-tag']
      },
    }
  }]
}
@d4rekanguok d4rekanguok added enhancement New feature or request help wanted Extra attention is needed labels Mar 27, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

1 participant