Docs Menu
Docs Home
/ /
Atlas App Services
/ /

GraphQL Configuration Files

On this page

  • Service Configuration
  • Custom Resolver Configuration

You can configure the GraphQL API for your application in the graphql directory:

app/
└── graphql/
├── config.json
└── custom_resolvers
└── <resolver name>.json
graphql/config.json
{
"use_natural_pluralization": <Boolean>,
"disable_schema_introspection": <Boolean>
}
Field
Description
use_natural_pluralization
boolean

true by default for new apps.

You can only set the value to false when you create a new app with the Admin API endpoint and pass the property into the body of the request. The value cannot be changed to false once the app is created.

If true, generated schema type names use common English pluralization whenever possible.

If false, or if a natural pluralization cannot be determined, then plural types use the singular type name with an "s" appended to the end.

Example

App Services can use either a natural plural or a default plural for a generated "mouse" type:

  • Natural: "mice"

  • Default: "mouses"

disable_schema_introspection
boolean

This value is false by default for new apps.

If true, the GraphQL API blocks introspection queries from clients.

This setting is useful for production Apps that do not want to expose their GraphQL schema to the public. When introspection is disabled, clients like GraphiQL cannot show docs for the API schema or autocomplete queries and mutations.

graphql/custom_resolvers/<resolver name>.json
{
"on_type": "<Parent Type Name>",
"field_name": "<Resolver Field Name>",
"function_name": "<Resolver Function Name>",
"input_type": "<Input Type Name>" | { <JSON Schema> },
"input_type_format": "<Input Type Format>",
"payload_type": "<Payload Type Name>" | { <JSON Schema> },
"payload_type_format": "<Payload Type Format>",
}
Field
Description
on_type
string

The parent type that exposes the custom resolver as one of its fields.

Valid Options:

field_name
string

The name of the field on the parent type that exposes the custom resolver. The field name must be unique among all custom resolver on its parent type.

If the field name matches a field in the parent type's schema, the custom resolver overrides the schema type.

function_name
string
The name of the function that runs when the resolver is called. The function arguments may accept a single argument (configured by input_type and input_type_format) and must return a payload value (configured by payload_type and payload_type_format).
input_type
string | object
The type of the resolver's input argument (if it accepts input). You can specify either the name of another type in your GraphQL schema or a custom JSON schema specific to the resolver.
input_type_format
string

A metadata description of the input_type.

Valid Options:

  • "scalar" (for a single value of a specific BSON type)

  • "scalar-list" (for multiple values of a specific BSON type)

  • "generated" (for a single value of a specific exposed type)

  • "generated-list" (for multiple values of a specific exposed type)

  • "custom" (for a custom JSON schema)

payload_type
string | object

The type of the value returned in the resolver's payload. You can specify either the name of another type in your GraphQL schema or a custom JSON schema specific to the resolver.

If you do not specify a payload type, the resolver returns a DefaultPayload object:

type DefaultPayload {
status: String!
}
payload_type_format
string

A metadata description of the payload_type.

Valid Options:

  • "scalar" (for a single value of a specific BSON type)

  • "scalar-list" (for multiple values of a specific BSON type)

  • "generated" (for a single value of a specific exposed type)

  • "generated-list" (for multiple values of a specific exposed type)

  • "custom" (for a custom JSON schema)

Back

Functions