-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Description
This is more a feature request/request about how you foresee gqlgen.
Usecase
Having the possibility to have two GraphQL endpoints with different schemas.
- A frontend has different requirements than a backend API
- A backend API/GraphQL Schema might expose nearly all fields of a database (e.g., for simple CURD operations or using the backend also as a different use case (ERP-System))
- In a frontend GraphlQL API you might don't want to expose all fields like in a backend API
Examples
... of things that might not be exposed:
- Shop: Purchasing costs for the supplier
- Blog: Flag if an article is published or not
- Data (imported): The source from where it gets imported
Discussions
A related discussion can be read at Splitting a GraphQL API between public & private.
Additionally, I asked this on Gitter, but there was no answer (yet).
Potential implementations
Supporting this
Based on what I know, not that much would be adjusted:
Either the config will be adjusted to support multiple schemas.
Or the generate command accepts arguments to point to a specific config.
This would need two different configurations.
Not sure how this would work with the traditional ´go generate` command.
From the server implementation, it could be possible already to start two instances and map the handlers to two endpoints.
The playground would need support to add the endpoint. But this might be a problem already solved by the community.
Advising two services
An alternative solution could be to don't support this and advise you to create two independent services. This would make the source code of gqlgen lean and not more complex.
Those two services would both act with the data storage.
Client A (Mobile client) <--------> Service A (Frontend) <--------> Database <--------> Service B (Backend) <--------> Client B (Backend-UI)
Challenges:
- Keeping implementations in sync
- (Possible) sharing source code/models if the schema is partially the same
Thoughts?
What are your thoughts on this?
Would this be an interesting feature? Or is the vision more to keep it lean and recommending multiple independent services in this case?