hasura / go-graphql-client

Package graphql provides a GraphQL client implementation.
MIT License
395 stars 91 forks source link

How can I change the type name use variable? #147

Open xift810 opened 1 month ago

xift810 commented 1 month ago

1111

we can use graphql tag to change type name But if we have different environment and different type name (product_xxxx), but graphql tag cannot using varaible and dynamic change . What can I do now? thx

xift810 commented 1 month ago

Maybe "Exec/ExecRaw" can do this?

hgiasac commented 1 month ago

Yes, Go tags can not be modified in runtime. If you want to build dynamic query strings Exec is the only option.

hgiasac commented 1 month ago

Btw, you can use the ContructQuery and ContructMutation functions to build the query string, then use strings.Replace to replace the query name and run with Exec.