Skip to content

GraphQL.js emulation: expand to resolveType and isTypeOf #2457

Closed
@benjie

Description

@benjie

resolveType and isTypeOf in Grafast currently (or will once #2301 is closed) only support (value: any) => string | GraphQLObjectType call signature. GraphQL.js supports (value: any, context: any, resolveInfo: GraphQLResolveInfo, abstractType: GraphQLUnionType | GraphQLInterfaceType) => PromiseOrValue<string | GraphQLObjectType> signature. Ideally we don't want Grafast having to handle all the complexities of this for most Grafast schemas, however if the schema includes GraphQL.js emulation then we will need to. We should therefore add a flag such as emulateGraphQLJS?: boolean that enables resolveType and isTypeOf to run in GraphQL.js emulation mode (with the additional properties) - we'd accomplish this by running resolveType as a step much like the graphqlResolver, that way it can be satisfied asynchronously if needed.

We should also add a flag to the relevant extensions: unionType.extensions.grafast.emulateGraphQLJS; if set true then we'd emulate GraphQLJS for the type, if false we wouldn't, and if unset we'd default to the global emulateGraphQLJS flag passed to the grafast() function (or via the preset or whatever).

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    Status

    ✅ Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions