You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+15-7Lines changed: 15 additions & 7 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,6 +1,6 @@
1
1
# Overview
2
2
3
-
graphql-codegen-hasura is a collection of code generator plugins for [graphql-code-generator](https://graphql-code-generator.com/). These plugins are designed to automate some coding tasks around the development of a strongly typed [Hasura](https://hasura.io/) backend with an [Apollo GraphQL](https://www.apollographql.com/) React client.
3
+
graphql-codegen-hasura is a collection of code generator plugins for [graphql-code-generator](https://graphql-code-generator.com/). These plugins are designed to automate coding tasks around the development of a strongly typed client for a [Hasura](https://hasura.io/) backend. The majority of the code generated is strongly-typed wrappers for [Apollo GraphQL](https://www.apollographql.com/), in addition to a number of convenience features.
4
4
5
5
## Approaches
6
6
@@ -18,6 +18,7 @@ These plugins require and augment the existing fantastic GraphQL code generator
18
18
- The **graphql-codegen-hasura-gql-from-documents** plugin generates [CRUD](https://en.wikipedia.org/wiki/Create,_read,_update_and_delete) gql mutations and queries for every _Fragment_ defined in the targeted (code) documents.
19
19
- The **graphql-codegen-hasura-typescript-from-schema** plugin generates [CRUD](https://en.wikipedia.org/wiki/Create,_read,_update_and_delete) TypeScript helper methods for every _Table_ defined in the Hasura database.
20
20
- The **graphql-codegen-hasura-typescript-from-documents** plugin generates [CRUD](https://en.wikipedia.org/wiki/Create,_read,_update_and_delete) TypeScript helper methods for every _Fragment_ defined in the targeted (code) documents.
21
+
- The **graphql-codegen-hasura-typescript-react-from-documents** (Experimental) plugin generates [CRUD](https://en.wikipedia.org/wiki/Create,_read,_update_and_delete) React Hooks for every _Fragment_ defined in the targeted (code) documents.
21
22
22
23
## Structure
23
24
@@ -107,6 +108,16 @@ See [graphql-code-generator documentation](https://graphql-code-generator.com/do
107
108
- withUpdates: boolean flag for update TypeScript code generation
108
109
- withDeletes: boolean flag for delete TypeScript code generation
- reactApolloVersion (2 | 3, default value: 3): sets the version of react-apollo
114
+
- typescriptCodegenOutputPath: import path to the code generated with dependent @graphql-codegen/typescript generated code
115
+
- trimString: optional string to trim from each type name. Useful for trimming Hasura prepended schema name
116
+
- withQueries: boolean flag for query Hooks code generation
117
+
- withInserts: boolean flag for insert Hooks code generation
118
+
- withUpdates: boolean flag for update Hooks code generation
119
+
- withDeletes: boolean flag for delete Hooks code generation
120
+
110
121
## Plugin Details
111
122
112
123
### graphql-codegen-hasura-gql-from-schema plugin
@@ -246,7 +257,7 @@ This has the same output as the [graphql-codegen-hasura-typescript-from-schema](
246
257
247
258
Generates [CRUD](https://en.wikipedia.org/wiki/Create,_read,_update_and_delete) TypeScript helper methods for every _Table_ defined in the Hasura database
248
259
249
-
The existing [@graphql-codegen/typescript-react-apollo](https://graphql-code-generator.com/docs/plugins/typescript-react-apollo) plugin already provides this capability for hooks. This plugin extends that to direct client.query & client.mutate calls, in addition to adding some convenience features.
260
+
Generates [CRUD](https://en.wikipedia.org/wiki/Create,_read,_update_and_delete) TypeScript helper methods for every _Fragment_ defined in the targeted (code) documents. Provides wrapped client.query & client.mutate calls, in addition to adding some convenience features.
250
261
251
262
See [demo/src/autogen/hasura/typescript-from-schema.ts](https://github.com/ahrnee/graphql-codegen-hasura/tree/master/demo/src/autogen/hasura) for generated output files.
252
263
@@ -354,9 +365,7 @@ export async function removeUsersModel(
354
365
355
366
#### Overview
356
367
357
-
Generates [CRUD](https://en.wikipedia.org/wiki/Create,_read,_update_and_delete) TypeScript helper methods for every _Fragment_ defined in the targeted (code) documents.
358
-
359
-
The existing [@graphql-codegen/typescript-react-apollo](https://graphql-code-generator.com/docs/plugins/typescript-react-apollo) plugin already provides this capability for hooks. This plugin extends that to direct client.query & client.mutate calls, in addition to adding some convenience features.
368
+
Generates [CRUD](https://en.wikipedia.org/wiki/Create,_read,_update_and_delete) TypeScript helper methods for every _Fragment_ defined in the targeted (code) documents. Provides wrapped client.query & client.mutate calls, in addition to adding some convenience features.
360
369
361
370
See [demo/src/autogen/hasura/typescript-from-documents.ts](https://github.com/ahrnee/graphql-codegen-hasura/tree/master/demo/src/autogen/hasura) for generated output files.
362
371
@@ -392,15 +401,14 @@ This code was initially developed for use in a single separate commercial projec
392
401
393
402
Known Issues Include:
394
403
395
-
- Hasura views will break the code generation
404
+
- Hasura views break the code generation
396
405
397
406
## Refinements and Enhancements Needed
398
407
399
408
There are many refinements and enhancements that would be beneficial, and contributions to that end are encouraged. Notable examples include:
400
409
401
410
- Fix known issues
402
411
- Add validation (especially for checking for package prerequisites). See [these docs](https://graphql-code-generator.com/docs/custom-codegen/validate-configuration)
403
-
- Extend capabilities to facilitate codegen for multi-table queries and mutations. One implementation strategy is to perhaps generate gql and helper code from user-defined gql fragments. Will require some design work.
404
412
- Rewrite the plugins to use the graphql-code-generator [recommended Visitor pattern](https://graphql-code-generator.com/docs/custom-codegen/using-visitor)
0 commit comments