-
Notifications
You must be signed in to change notification settings - Fork 4
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
Plularization of the queries #28
Comments
@machi1990 @craicoverflow This is something I have totally overlooked. What would be your take? |
@wtrocki thanks for opening this issue which is well summarized.
+1 on this solution.
This is the main concern I had with pluralising.
Wait till you hear the different varieties there are in French language. |
I was talking @ralfhandl the other day about how OData deals with this and there is an explicit definition of the model - model can be singleton or array - In case of the graphql crud we assume that everything is array and there are no singletons, but the benefit of splitting model definition and it's the actual name in query, update thing can be beneficial. This is also what @danielrearden mentioned to me - names should be controllable - so we do not have any artificial variants that differ only by name. However I find it hard to reflect plural in SDL. Would something like this make sense:
Seems overkill to me |
Another crazy idea. Instead of dealing with names we can specify operations and mappings - and even build specific implementation for the language of the choice. This will mean that spec itself will abstract from the name - what you will get is just crud operations with certain capabilities and names itself would be coming from individual implementation. This will allow us to define mappings to various different solutions - we can map (and transform) from Prisma, Hasura, AppSync in seconds - or throw errors if someone using capability that other platform is not using. |
I don't see this as an issue with GraphQLCRUD. I see this as an issue with how it is implemented in Graphback.
Removing all pluralization will become confusing for users of the API:
If above were to happen, it is not obvious what the difference between both queries are. Pluralization is very important in identifying the action of a resolver/method. If everything is singular the schema API becomes less clear. |
@craicoverflow but following your comment. How do you see us to remove ambiguity in spec? |
FWIW, some APIs (like Hasura's) don't bother with the distinction between singular and plural at all. If you did drop the pluralization, something like |
WRT Graphback specifically, you could add a plugin config option for an operation name template map with some reasonable defaults operationNames:
findById: '${MODEL}ById'
findAll: 'find${MODEL}'
# create, update, etc. |
I think we want to go above graphback here. Graphback (or more specifically GraphQL-serve) is a tool that allows people to print out compatible schema, but if you as the creator will need to adjust your own tool to be compatible just by names that will be bummer - Introducing breaking changes to users. I will check how we can do this mapping - in both documentation and tooling and see if that is doable. My use case is simple - I'm building tons of UI/Client side tools and want them to work. This means that my tools can supply different versions of the queries to different providers, but if graphql crud will deal with this then it could be much easier for people to adopt it and it will bring a lots of value. |
Great idea! We need here short term plan and long term. For the short term, I propose non pluralized names. For the long term, we will introduce the concept of features and how they are composed in queries which will allow us to map any names used for queries in implementations like AppSync, Hasura, Prisma etc. Any opinions? |
For the short term this would mean completely changing the semantic structure of the query names so that they make sense. Simply dropping plurality from the existing names mean that they will single v plural queries become indistinguishable, eg: getTask v findTask. So as @danielrearden suggested a way to distinguish these is to use something like |
The short term solution should be easy to map and possibly the default one once the long term solution is there. To avoid ambiguities of the queries, I second what @craicoverflow @danielrearden proposed, instead of |
After today's call, |
Perfect! This change would be really beneficial. |
English language as many others have plural versions.
What it means that
findTask
is different thanfindTasks
operation can be comefind
Object
[s,ss,sh]
etc. Having plurals brings confusion to the spec - especially when developers dealing with models that might not be easily pluralized.Current implementations in javascript using pluralize library that has some specific rules but other languages will have different ones.
We are hitting this issue when building client side queries for graphback.
Solution:
getTask
andtask
- as the plural query.s
even if the form will not be validThe text was updated successfully, but these errors were encountered: