Adding your own Queries and Mutations

You can add your own GraphQL queries and mutations to Payload, making use of all the types that Payload has defined for you.

To do so, add your queries and mutations to the main Payload config as follows:

Config PathDescription
graphQL.queriesFunction that returns an object containing keys to custom GraphQL queries
graphQL.mutationsFunction that returns an object containing keys to custom GraphQL mutations

The above properties each receive a function that is defined with the following arguments:


This is Payload's GraphQL dependency. You should not install your own copy of GraphQL as a dependency due to underlying restrictions based on how GraphQL works. Instead, you can use the Payload-provided copy via this argument.


This is a copy of the currently running Payload instance, which provides you with existing GraphQL types for all of your Collections and Globals - among other things.

Return value

Both graphQL.queries and graphQL.mutations functions should return an object with properties equal to your newly written GraphQL queries and mutations.



import { buildConfig } from 'payload/config';
import myCustomQueryResolver from './graphQL/resolvers/myCustomQueryResolver';
export default buildConfig({
serverURL: 'http://localhost:3000',
graphQL: {
queries: (GraphQL, payload) => {
return {
MyCustomQuery: {
type: new GraphQL.GraphQLObjectType({
name: 'MyCustomQuery',
fields: {
text: {
type: GraphQL.GraphQLString,
someNumberField: {
type: GraphQL.GraphQLFloat,
args: {
argNameHere: {
type: new GraphQL.GraphQLNonNull(GraphQLString),
resolve: myCustomQueryResolver,