genqlient
genqlient copied to clipboard
Add config for remote schemas
Is your feature request related to a problem? Please describe. I don't want to have to manually update the schema.graphql file.
Describe the solution you'd like
Add RemoteSchemaURL
to generate/config.go
. Temporarily download this file to disk for generation.
Describe alternatives you've considered I currently have a ci job to download the remote schema and compare it to the schema in my project
I see a bunch of thumbs up here -- thanks for filing the issue and for those who expressed interest.
It should be easy enough to do a simple version of this (PRs are welcome or I may have time eventually), but my question is whether that's enough. For those who were interested, is just fetching the file from a fixed URL as a GET with no auth sufficient for you, or would you also need a way to configure the fetch further?
cc @connec @reiishikawa1208 @lzakharov @Diaga @wdoug
For my use case, I would need to specify custom headers for auth and specifying user roles. Specifying method GET/POST may also be needed.
Here is what I am used to in JS environment: https://www.graphql-code-generator.com/docs/config-reference/schema-field#method https://www.graphql-code-generator.com/docs/config-reference/schema-field#headers
I would also love to see this feature. My use case is I have a running Dgraph database, which has a running (and Dgraph augmented) schema. This includes many mutations and queries. The issue is pulling this from the local dev dgraph install, which is my problem to set up of course.
I can use the npm tool get-graphql-schema http://10.45.220.6:8080/graphql
to fetch it in the proper format, of course.
@Diaga thanks for the links to the JS version, that will be a helpful reference!
@skandragon if you're fetching from a local install, is that on a fixed IP/port? Is that SDL format or introspection query? I think supporting via introspection query is going to be a fair amount of work, because we'd have to implement the transform in Go. If someone wants to do it (or better if there's a package we can pull in), that would be great, but I expect fetching SDL will be the first step.
@skandragon if you're fetching from a local install, is that on a fixed IP/port? Is that SDL format or introspection query? I think supporting via introspection query is going to be a fair amount of work, because we'd have to implement the transform in Go. If someone wants to do it (or better if there's a package we can pull in), that would be great, but I expect fetching SDL will be the first step.
What I really want is a way to take the SDL format input, and have what dgraph would use as output, on the command line.
My work flow is currently:
- submit the schema to dgraph via a POST to /admin
- get the schema back via the npm tool
get-graphql-schema
and write it to a file. - run the Go tool
go run github.com/Khan/genqlient
to generate graphql code for my Go app
I cannot feed the user-side schema I write to genqlicent, as it will not have all the components needed.
I cannot feed the user-side + dgraph fragment for IDEs in, as that won't generate the queries or mutations.
So, my option is to submit to dgraph, and pull the resulting full schema out. I'd really just like to do that without running dgraph, although I will then run dgraph for my unit tests of course.