v2.1
Generates GraphQL client types, based on the schema introspection
Repository
Current version released
3 years ago
Dependencies
std
Gen. GraphQL Client
Work with your graphql endpoints type-safed way.
The script will do the schema introspection and next map it to typescript types.
Requirements
- Deno (
curl -fsSL https://deno.land/x/install/install.sh | sh)
You can think about Deno as a modern version of python, or “node.js done right”.
Deno is used only for type generation, next you can use the generated file with node.js as well, it’s a regular typescript file.
How to use
Minimal:
deno run -A https://deno.land/x/gen_graphql@v2.0/gen.ts http://localhost:5000/graphqlAdvanced:
deno run -A https://deno.land/x/gen_graphql@v2.0/gen.ts -e http://localhost:5000/graphql -o src/graphql.generated.ts --prefix GqlParams
-e- GraphQL endpoint url-o- Generated output file path (defaultgraphql.generated.ts)--prefix- Prefix for generated types--enums- Generate enums instead of ts union types for GraphQL Enums--defaultFragment- Generate default fragments for queries with all fields (level 1 only)--fetch- Usefetchinstead ofApollo Client(zero dependency)
React
Check out react folder for examples