typed-graphqlify
Build Typed GraphQL Query in TypeScript. Better TypeScript + GraphQL experience.
Install
yarn add typed-graphqlify
Example
First, define GraphQL-like JS Object:
Note that we use our types
helper to define types in the result.
Then, convert the JS Object to GraphQL (string) with graphqlify
:
console.loggqlString// =>// query getUser {// user {// id// name// isActive// bankAccount {// id// name// }// }// }
Finally, execute the GraphQL:
// We would like to type this! // As we cast `result` to `typeof getUser`,// Now, `result` type looks like this:// interface result {// user: {// id: number// name: string// bankAccount: {// id: number// branch: string// }// }// }
TODO
- Publish to NPM
- Enum support
- Variable Input support
Thanks
Inspired by https://github.com/kadirahq/graphqlify