Closed karanpratapsingh closed 4 years ago
CHANGELOG
codegen.yml
web/src/graphql/operations.tsx
generate:schema
generate:graphql
Now with the generated web/src/types/graphql.tsx we can simply use typesafe query/mutation hooks generated from backend/packages/graphql/api rather than declaring twice (on web and backend)
web/src/types/graphql.tsx
backend/packages/graphql/api
Example:
import { GET_USER_QUERY } from '@web/graphql'; const variables = { input: { id: 'demo_user_id' } }; const { data, loading, error } = useQuery(GET_USER_QUERY, { variables });
The above can now be written as:
import { useGetUserQuery } from '@web/graphql'; const variables = { input: { id: 'demo_user_id' } }; const { data, loading, error } = useGetUserQuery({ variables });
Thanks to @capaj for suggesting this improvement
thanks @karanpratapsingh. This is a great improvement.
Glad you liked it 😁
CHANGELOG
codegen.yml
configweb/src/graphql/operations.tsx
generate:schema
->generate:graphql
Now with the generated
web/src/types/graphql.tsx
we can simply use typesafe query/mutation hooks generated frombackend/packages/graphql/api
rather than declaring twice (on web and backend)Example:
The above can now be written as:
Thanks to @capaj for suggesting this improvement