Possible Resolver Types
See original GitHub issueHi 👋,
while looking at the source code of graphql-yoga
and graphql-js
I found out that resolvers can take different “shapes”.
So far, I have found GraphQLFieldResolver
and GraphQLScalarType
which have very similar structure, IResolverOptions
which handles subscriptions, and a special case when using Fragments
.
interface IResolverOptions {
resolve?: GraphQLFieldResolver<any, any>
subscribe?: GraphQLFieldResolver<any, any>
__resolveType?: GraphQLTypeResolver<any, any>
__isTypeOf?: GraphQLIsTypeOfFn<any, any>
}
type GraphQLFieldResolver = Promise
type GraphQLScalarType = Promise
interface WithFragment {
fragment: string
resolve: GraphQLFieldResolver<any, any>
}
Are there any other types/cases?
PS.: Is
WithFragment
case the same asIResolverOptions
?
EDIT:
withFragment
const resolver = {
fragment: `fragment Likes on User { id }`,
resolve: async ({ id }, args, ctx, info) => {
return 0
}
}
IResolverOptions
const resolver = {
resolve: async ({ id }, args, ctx, info) => {
return 'something'
}
}
Since both of these have resolve
option and resolvers
part is nowhere explicitly defined, I thought they might be of the same Type
.
Issue Analytics
- State:
- Created 6 years ago
- Comments:6 (3 by maintainers)
Top Results From Across the Web
Resolvers - Apollo GraphQL Docs
There are GraphQL types that enable you to define a field that returns one of multiple possible object types (i.e., unions and interfaces)....
Read more >Resolver (electrical) - Wikipedia
A resolver is a type of rotary electrical transformer used for measuring degrees of rotation. It is considered an analog device, and has...
Read more >Resolvers - What Are They and How Do They Work? | Dynapar
Common applications of resolvers include: Servo motor feedback. Speed and position feedback in steel and paper mills.
Read more >Resolvers – GraphQL Tools
Resolvers in GraphQL can return different kinds of results which are treated differently: ... A promise - resolvers often do asynchronous actions ...
Read more >A Guide to Common Resolver Patterns - Prisma Tutorials
Learn about common resolver patterns.
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 Free
Top 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
I’d love to hear @IvanGoncharov’s thoughts on this as he’s very familiar with the graphql-js implementation.
Hey 👋, It seems like this issue has been inactive for some time. In need for maintaining clear overview of the issues concerning the latest version of
graphql-yoga
we’ll close it. Feel free to reopen it at any time if you believe we should futher discuss its content. 🙂