Skip to content

Commit 75e3a08

Browse files
committed
documentation updates
1 parent 5f71c64 commit 75e3a08

File tree

1 file changed

+15
-7
lines changed

1 file changed

+15
-7
lines changed

README.md

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Overview
22

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.
44

55
## Approaches
66

@@ -18,6 +18,7 @@ These plugins require and augment the existing fantastic GraphQL code generator
1818
- 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.
1919
- 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.
2020
- 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.
2122

2223
## Structure
2324

@@ -107,6 +108,16 @@ See [graphql-code-generator documentation](https://graphql-code-generator.com/do
107108
- withUpdates: boolean flag for update TypeScript code generation
108109
- withDeletes: boolean flag for delete TypeScript code generation
109110

111+
### graphql-codegen-hasura-typescript-react-documents plugin
112+
113+
- 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+
110121
## Plugin Details
111122

112123
### graphql-codegen-hasura-gql-from-schema plugin
@@ -246,7 +257,7 @@ This has the same output as the [graphql-codegen-hasura-typescript-from-schema](
246257

247258
Generates [CRUD](https://en.wikipedia.org/wiki/Create,_read,_update_and_delete) TypeScript helper methods for every _Table_ defined in the Hasura database
248259

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.
250261

251262
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.
252263

@@ -354,9 +365,7 @@ export async function removeUsersModel(
354365

355366
#### Overview
356367

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.
360369

361370
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.
362371

@@ -392,15 +401,14 @@ This code was initially developed for use in a single separate commercial projec
392401

393402
Known Issues Include:
394403

395-
- Hasura views will break the code generation
404+
- Hasura views break the code generation
396405

397406
## Refinements and Enhancements Needed
398407

399408
There are many refinements and enhancements that would be beneficial, and contributions to that end are encouraged. Notable examples include:
400409

401410
- Fix known issues
402411
- 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.
404412
- Rewrite the plugins to use the graphql-code-generator [recommended Visitor pattern](https://graphql-code-generator.com/docs/custom-codegen/using-visitor)
405413

406414
## Notes

0 commit comments

Comments
 (0)