#GraphQL Code Gen

3 messages · Page 1 of 1 (latest)

shrewd veldt
#

I'm trying to use GraphQL CodeGen to ensure that the type I get back from a GraphQL API is correct and has the appropriate type in TypeScript. There's no loader for.graphql files, which is fine. I move the.graphql files outside of the convex directory. When I try to import a query I define in a.graphql file, in a convex file, I still hit the error that says no loader is configured for.graphql files.

So is it even possible to use graphql-codegen? And if not, what do you suggest to make sure that the response from graphql-api has appropriate types?

sonic topazBOT
#

Hi @shrewd veldt. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:

#

Hmm, I don't know enough to give you a confident answer yet. The knowledge sources provided do not contain specific information about using GraphQL CodeGen with Convex. However, Convex does use code generation to create code that is specific to your app's data model and API, generating JavaScript files (.js) with TypeScript type definitions (.d.ts). This could potentially help with ensuring the response from your API has appropriate types.

To generate the code in Convex, you can run:

npx convex dev  

This creates a convex/_generated directory that contains api.js and api.d.ts, dataModel.d.ts, server.js and server.d.ts files.

For more detailed information, you might want to check the Convex documentation on Generated Code (https://docs.convex.dev/generated-api/).

Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: