[PROP] Improved names for List/Field graphql related methods
See original GitHub issueThe List
and Field
methods which are used to build the graphQL schema and resolvers are confusing for developers (citation needed).
This proposal suggests a different set of method names which should make it easier to follow and understand the code.
To begin with, let’s look at the current names. This are grouped into graphQL type definition related methods, and resolver definition related methods.
Each List
method calls zero or more Field
methods, as listed.
Type definitions
list.getAdminGraphqlTypes
field.getGraphqlOutputFields
field.getGraphqlQueryArgs
field.getGraphqlUpdateArgs
field.getGraphqlCreateArgs
field.getGraphqlAuxiliaryTypes
list.getAdminGraphqlQueries
field.getGraphqlAuxiliaryQueries
list.getAdminGraphqlMutations
field.getGraphqlAuxiliaryMutations
Resolvers
list.getAuxiliaryTypeResolvers
field.getGraphqlAuxiliaryTypeResolvers
list.getAdminFieldResolvers
field.getGraphqlOutputFieldResolvers
list.getAuxiliaryQueryResolvers
field.getGraphqlAuxiliaryQueryResolvers
list.getAdminQueryResolvers
list.getAuxiliaryMutationResolvers
field.getGraphqlAuxiliaryMutationResolvers
list.getAdminMutationResolvers
Proposed Changes
There are two groups of proposed changes below:
- In
List
methods,getAdmin...()
becomesget...()
. TheAdmin
token doesn’t have any meaning here and can be removed. - In
Field
methods,getGraphql...Resolvers
becomesget...Resolvers
. This makes them consistent with the relatedList
methods, which do not contain theGraphql
token in their names.
Also, rather than renaming getAdminFieldResolvers
to getFieldResolvers
, we call it getListTypeResolvers
. This makes it more clear what it is doing when paired with getAuxiliaryTypeResolvers
in Keystone/index.js
.
Changes
list.getAdminGraphqlTypes -> list.getGraphqlTypes
list.getAdminGraphqlQueries -> list.getGraphqlQueries
list.getAdminGraphqlMutations -> list.getGraphqlMutations
list.getAdminFieldResolvers -> list.getListTypeResolvers
list.getAdminQueryResolvers -> list.getQueryResolvers
list.getAdminMutationResolvers -> list.getMutationResolvers
field.getGraphqlOutputFieldResolvers -> field.getOutputFieldResolvers
field.getGraphqlAuxiliaryTypeResolvers -> field.getAuxiliaryTypeResolvers
field.getGraphqlAuxiliaryQueryResolvers -> field.getAuxiliaryQueryResolvers
field.getGraphqlAuxiliaryMutationResolvers -> field.getAuxiliaryMutationResolvers
Type definitions
list.getGraphqlTypes
field.getGraphqlOutputFields
field.getGraphqlQueryArgs
field.getGraphqlUpdateArgs
field.getGraphqlCreateArgs
field.getGraphqlAuxiliaryTypes
list.getGraphqlQueries
field.getGraphqlAuxiliaryQueries
list.getGraphqlMutations
field.getGraphqlAuxiliaryMutations
Resolvers
list.getAuxiliaryTypeResolvers
field.getAuxiliaryTypeResolvers
list.getListTypeResolvers
field.getOutputFieldResolvers
list.getAuxiliaryQueryResolvers
field.getAuxiliaryQueryResolvers
list.getQueryResolvers
list.getAuxiliaryMutationResolvers
field.getAuxiliaryMutationResolvers
list.getMutationResolvers
Pros
- All type definition methods follow the pattern
getGraphql<plural>
, indicating that they will return a list graphQL snippets. - All resolver methods follow the pattern
get...Resolvers
, indicating that they return a collection of resolvers. - The token
Admin
does not appear in any of the methods, which is as it should be, since these methods have nothing to do with the admin client.
Cons
- None 😉
Issue Analytics
- State:
- Created 5 years ago
- Comments:6 (6 by maintainers)
Top Results From Across the Web
Queries - Apollo GraphQL Docs
When your component renders, useQuery returns an object from Apollo Client that contains loading , error , and data properties you can use...
Read more >GraphQL List - How to use arrays in GraphQL schema ...
GraphQL List, how to use arrays in your GraphQL schema. Applying array on GraphQL type. Implementing GraphQL modifiers. How to design mutations and...
Read more >Queries and Mutations
On this page, you'll learn in detail about how to query a GraphQL server. Fields#. At its simplest, GraphQL is about asking for...
Read more >Prisma Client API (Reference)
name property of @@unique attribute - default is firstname_lastname ... createMany to create multiple related records - each technique pros and cons ....
Read more >GraphQl filter in list field - node.js
I'm not sure if that's the correct method to apply the filter, it worked for me when I use it for single-value fields,...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
It went through with the abbreviated names as proposed. I’m not that strongly opinionated, so am happy with the results in https://github.com/keystonejs/keystone-5/pull/284 👍
@jesstelford I’m generally not a fan of shortening words either but in cases like this, where there are so many constructs relating to a specific area (
GraphQL
), it does make the code significantly less verbose. I’m more comfortable aboutAux
; it’s so often abbreviated and, in this context, quite unambiguous.Regardless, did you and @timleslie bottom out on this before the merge? I didn’t intend to ignore your feedback!