graphql-go
graphql-go copied to clipboard
Expose Validate API?
Hi team, I am hoping use it to write a "gateway" plugin for Traefik to further limit the queries exposed by Hasura GraphQL Engine.
The Validate API is so useful! Currently it is in internal folder.
https://github.com/graph-gophers/graphql-go/blob/5a1c1721f1b3d0c600222327f4a6d1dd5dd1d50c/internal/validation/validation.go#L68
I am wondering is it possible to expose this Validate API? So we can leverage this API to do more work.
Thank you so much! 😊
What exactly would you like to achieve and how moving the validation API would help you?
Hi @pavelnikolov , basically, we hope to validate a GraphQL query based on a schema. Like another API at https://github.com/vektah/gqlparser/blob/master/validator/validator.go#L25 However, this API does not support depth limit check.
For the validate API in this library at https://github.com/graph-gophers/graphql-go/blob/5a1c1721f1b3d0c600222327f4a6d1dd5dd1d50c/internal/validation/validation.go#L68
Due to internal package not allowed, I think if we move it out of internal folder, then we can use it.
Please correct me if I am wrong. Thanks! 😃
The reason many of the APIs were in the internal folder is that it allowed the creators of this library to introduce breaking changes to those API. As the API becomes more mature over time it might make sense to move some of the APIs out of the internal folder. Until recently the types were also internal. However, now that they are public it might make sense to make the validation public as well. Why is this feature needed. Why wouldn't you validate the schema by the server itself?
Hi @pavelnikolov thanks! I think I can close this one, as at that time I copied the code from this repo out and directly import and still not work due to some customized Traefik plugin limitations.