Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow different schemas for different file paths #76

Open
kedarguy opened this issue Jun 12, 2022 · 0 comments
Open

Allow different schemas for different file paths #76

kedarguy opened this issue Jun 12, 2022 · 0 comments

Comments

@kedarguy
Copy link

kedarguy commented Jun 12, 2022

Example use case:

Next.js app where the API routes can call the graphql API as admins vs the frontend that can call the API as authenticated users.

Example config from graphql-code-generator config which allows a similar behaviour:

module.exports = {
  generates: {
    './types/codegen/index.ts': {
      schema: [
        {
          [`https${process.env.NEXT_PUBLIC_API_URL}`]: {
            headers: {
              'X-Hasura-Admin-Secret': XXXXXX,
              'X-Hasura-Role': 'User',
            },
          },
        },
      ],
      documents: [
        './pages/**/*.tsx',
        './components/**/*.tsx',
        './utils/**/*.tsx',
      ],
    },
    './types/codegen/admin-generated.ts': {

      schema: [
        {
          [`https${process.env.NEXT_PUBLIC_API_URL}`]: {
            headers: {
              'X-Hasura-Admin-Secret': XXXXXX,
              'X-Hasura-Role': 'Admin',
            },
          },
        },
      ],
      documents: ['./pages/api/**/*.ts'],
    },
  },
};

┆Issue is synchronized with this Jira Task by Unito

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

No branches or pull requests

1 participant