it seems like i need some help with this, because i was looking for a solution for a while now.
I created an angular project using graphql and configured the apollo client for that. In the backend i'm using laravel with the rebing/graphql extension. Now i'd like to extract some typescript interfaces from my schema to use them in my logic. A while ago i started to develop my own little system in which i dynamically generate gql queries from json definition during runtime. I guess, that's something which could get challenged too - i guess.. Thats why there are no real graphql query definitions in my code itself. I do not use any .gql/.graphql files.
My graphql query are create with something like:
UserModel.with('posts', { pagination: 10, offset: 0 }).get() <-- QueryRef
What i try to say is that, this way, i can not easily start the apollo typescript generator to search for any graphql queries in my project to genereate types.
I already managed it to download my schema from the endpoint like so:
apollo client:download-schema ./libs/graphql/src/lib/schema.graphql --endpoint https://api.ellingtons-palace.com/graphql
It works quite nice. That way i can get either grapqhl or json schemas.
What i'm not able to, is generate typescript files of interaces to use in my code. I tried it like that:
apollo codegen:generate --localSchemaFile=libs/graphql/src/lib/schema.json --target=typescript --includes=libs/graphql/src/lib/schema.graphql --tagName=graphql --addTypename --globalTypesFile=libs/graphql/src/lib/graphql-global-types.ts
Unfortunately, everytime i get errors like:
The type of your project could not be derived from your config.
or
Field "UserType.Locations" already exists in the schema. It cannot also be defined in this type extension.
Is there someone who can tell me what i'm doing wrong, or what options there could be to convert my schema to valid typescript?
Thanks in advance!!
Greets Jules ;)