Symfony | Api Platform | GraphQL | Apollo | TypeScript | React Hooks
Install Api Platform
composer req apiInstall GraphQL
composer req webonyx/graphql-phpInstall apollo and graphql
yarn add apollo-boost @apollo/react-hooks graphqlInstall codegen for typescript this will generate the types and interfaces automatically
yarn add @graphql-codegen/cli @graphql-codegen/typescriptConfigure codegen
# codegen.yml
schema: http://localhost:8000/api/graphql
generates:
src/services/graphql/types.ts:
- typescriptrun codegen to generate the types in src/services/graphql/types.ts
yarn graphql-codegen
In case you are using SSL on your localhost:8000, run the command like this:
NODE_TLS_REJECT_UNAUTHORIZED=0 yarn graphql-codegenAlso, if you implemented JWT auth to access your graphql endpoints, use this codegen configuration: