-
-
Notifications
You must be signed in to change notification settings - Fork 31
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Resolving User fields within the GQL schema #202
Comments
I'm going to have a stab at this. As of now Auth0 is our source of truth for user data. I'm hesitant to duplicate that information here. For the time being, as you pointed out, we only store user UUIDs in the database, without the human-friendly nicknames which are needed on openbeta.io. It'd be great to resolve user name in the backend. I think we can add a simple association collection to help us resolve user
|
I wasn't actually thinking of putting user data inside the mongo schema - rather allowing resolution of public user fields in the schema. So the resolver layer would make the requests that NextJS is currently making. In the mongo database we really only NEED uuids for the time being 🤔 My thinking is the API is maximally useful to developers when the schema is complete, and doesn't resolve IDs divorced from nodes. I do think it's a good idea to keep |
Let's put this one our next milestone, v0.7 |
I'm addressing this at the GQL layer in PR #273. All queries that return user uuid now return a user name. For the time being we still rely on resolving username by fetching |
Why 🤔
The ability to have a comprehensive entity schema is the main upside of GraphQL. Being able to compose queries of all kinds is a massive bonus, and will encourage developers to implement more features on OpenTacos with a vastly softer learning curve - and a much easier local development setup.
leaving these resolves to Next
/api
calls is an under-utilization of GraphQL's core offering that may result in over lock-in to the NextJS framework if not addressed now.Problem Spec
As the offering for Posts and Contributions evolve, having a more comprehensive GQL schema definition will improve developer ergonomics and could potentially reduce developer on-boarding friction in the future.
Gives sufficiently authorized developers a road to resolving users themselves, but adds an unreachable or frustrating step for new devs who are unfamiliar with the service structure.
editedBy: String
also does not communicate anything about the schema data relationship - another benefit of GQL schemasCurrent model
I believe the current model would have NextJS do an additional fetch/join to get this data from Auth0. The proposal made here is to move that logic into the resolver to improve API ergonomics for current and incoming API functionality. The upcoming post mechanics being an example.
Resolving within a single GQL endpoint is going to become increasingly desirable as contributions become more fleshed out, and we will inevitably end up with masses of relational data in the mongo data-store (Ticks, Posts, media, change-history, comments).
Additionally, if we were ever to experiment with alternate U.I frameworks we would need to commit to much more work and technical risk, than if principal data were all available through a single GQL endpoint.
Proposed Solution
Add an additional type to the schema, making a more holistic experience for API consumers.
The type would naturally not expose any private user data, and would return the same data available within the various api handlers already extant within OpenTacos.
which could allow resolution for current and future types in the schema:
The above proposed
User
type is far from comprehensive, and I would suggest that a number of other relational resolvers would be sensible, something like:I don't intend to make the above type a part of this proposal; discussion will need to take place about what is appropriate to expose in the schema, and it can be added progressively after an initial implementation for simple field revolvers.
The text was updated successfully, but these errors were encountered: