types

Contents

Add custom GraphQL types

Usage

It must be an object with the following structure:

types: {
    <GraphQLTypeName>: {
        description: <description>,
        interfaces: [
            <InterfaceGraphQLType>,
            // the rest of interface types...
        ],
        fields: {
            <fieldName>: {
                type: <graphQLType>,
                args: {
                    <argName>: <graphQLType>,
                    // the rest of argument definitions ...
                }
            },
            ...
        },
    },
    ...
}

For example:

types: {
    CustomInterfaceImpl: {
        description: 'CustomInterface Implementation',
        interfaces: [graphQL.reference('CustomInterface')],
        fields: {
            query: {
                type: graphQL.list(graphQL.GraphQLString),
                args: {
                    filter: graphQL.reference('CustomFilterInput')
                }
            },
            extraField: {
                type: graphQL.GraphQLString,
            }
        }
    }
}

According to GraphQL specification an implementation of an interface must implement all fields of the interface.


Contents

Contents

AI-powered search

Juke AI