types
Contents
Add custom GraphQL types
Usage
Add definitions to the types property returned by your extension function. Each key is the name of a GraphQL type. This example implements CustomInterface from Interfaces and uses CustomFilterInput from Input types; include both definitions in the same extension.
import type {Extensions, GraphQL} from '@enonic-types/guillotine';
export const extensions = (graphQL: GraphQL): Extensions => {
return {
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.