typeResolvers

Contents

Set or override type resolver for a union or interface.

Usage

It must be an object with the following structure:

{
    typeResolvers: {
        <GraphQLTypeName>: function (obj) {
            // your code here
        },
        // the rest of type resolvers ...
    }
}

For example:

{
    typeResolvers: {
        CustomInterface: function (obj) {
            return 'CustomInterfaceImpl';
        },
        CustomUnion: function (obj) {
            if (obj.title) {
                return 'GraphQLTypeNameOne';
            }
            return 'GraphQLTypeNameTwo';
        },
    }
}

Contents

Contents

AI-powered search

Juke AI