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

Maintaining end & README.md update #653

Open
kornfleks opened this issue Jun 28, 2023 · 0 comments
Open

Maintaining end & README.md update #653

kornfleks opened this issue Jun 28, 2023 · 0 comments

Comments

@kornfleks
Copy link

Hello,

As graphql-let is not actively maintains anymore, I think a disclaimer should be add at the start of the README file.

Two years ago I add the opportunity to use this tool and it has been the greatest dev experience I had with GraphQL & React. I really want to thanks @piglovesyou and others maintainers for producing this tool.

As today, I again have to use GraphQL with React (nextjs) in a monorepo, I am facing the same tooling hell where you don't know what to choose and how to configures it.

I have ended up using GraphqlCodegen and succeed to mimic the experience of graphql-let.

Here is how I did it:

For each .graphql files generate a .graphql.ts.
codegen.ts:

const config: IGraphQLConfig = {
  // using projects to support multiple GraphQL schema
  projects: {
    admin: {
      schema:  'http://localhost:8080/v1/graphql',
      extensions: {
        codegen: {
          generates: {
            './src/admin.ts': {
              config: generateConfig,
              plugins: ['typescript'],
            },
            admin: {
              preset: 'near-operation-file',
              presetConfig: {
                extension: '.graphql.ts',
                baseTypesPath: '~@foo-bar/graphql-codegen/src/admin',
              },
              documents: [
                '../../apps/**/src/pages/api/**/*.graphql',
              ],
              plugins: ['typescript-operations', 'typed-document-node'],
              config: generateConfig,
            },
          },
        }
      },
    },
    // ...
  }
}

To be able to do import like import { MyDocument } from './foo.graphql' we have to resolves the alias in the webpack config.
webpack.config.js:

{
  resolve: {
    extensionAlias: {
      '.graphql': ['.graphql.ts'],
    },
  }
}

You can also hide the .graphql.ts files from your editor so you don't even thinks about the code generation.

Best regards.

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