question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Possible Resolver Types

See original GitHub issue

Hi 👋,

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 as IResolverOptions?

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:closed
  • Created 6 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
schicklingcommented, Feb 19, 2018

I’d love to hear @IvanGoncharov’s thoughts on this as he’s very familiar with the graphql-js implementation.

0reactions
stale[bot]commented, Nov 30, 2018

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. 🙂

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found