graphql-let
graphql-let copied to clipboard
Maintaining end & README.md update
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.