Docs Menu

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>
}
Field
Description
use_natural_pluralization
Boolean

If true, Realm uses the common English pluralization of a type name whenever possible.

If false, or if Realm cannot determine a natural pluralization, the default plural type is the singular type with an "s" appended to the end.

Example

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

  • Natural: "mice"
  • Default: "mouses"
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 | JSON Schema
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 | JSON Schema

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)
Give Feedback
© 2021 MongoDB, Inc.

About

  • Careers
  • Legal Notices
  • Privacy Notices
  • Security Information
  • Trust Center
© 2021 MongoDB, Inc.