Create a custom resolver

POST /groups/{groupId}/apps/{appId}/graphql/custom_resolvers

Create a new custom resolver.

Path parameters

application/json

Body Required

  • on_type string Required

    The name of the resolver's parent type. This can be "Query", "Mutation", or the name of a generated type if this is a computed property.

  • field_name string Required

    The name of the custom resolver field that appears in the GraphQL schema.

  • input_type string | object

    The type of the custom resolver's input parameter. This can be a scalar, the name of an existing generated type, or a custom JSON schema object. If undefined, the resolver does not accept an input.

  • input_type_format string

    The kind of input type the custom resolver uses. This value must agree with the value of input_type:

    • A scalar input type must use "scalar" or "scalar-list"
    • A generated input type must use "generated" or "generated-list"
    • A custom input type must use "custom"

    If undefined, the resolver does not accept an input.

    Values are scalar, scalar-list, generated, generated-list, or custom.

  • payload_type string | object

    The type of the value returned by the custom resolver. This can be a scalar, the name of an existing generated type, or a custom JSON schema object.

    If undefined, the resolver returns a DefaultPayload object:

    type DefaultPayload {
      status: String!
    }
    
  • payload_type_format string

    The kind of payload type the custom resolver uses. This value must agree with the value of payload_type:

    • A scalar payload type must use "scalar" or "scalar-list"
    • A generated payload type must use "generated" or "generated-list"
    • A custom payload type must use "custom"

    If undefined, the resolver returns a DefaultPayload object.

    Values are scalar, scalar-list, generated, generated-list, or custom.

  • _id string

    The custom resolver's unique ID.

  • function_id string

    The resolver function's unique ID.

Responses

  • 201 application/json

    Created

    Hide response attributes Show response attributes object
    • on_type string Required

      The name of the resolver's parent type. This can be "Query", "Mutation", or the name of a generated type if this is a computed property.

    • field_name string Required

      The name of the custom resolver field that appears in the GraphQL schema.

    • input_type string | object

      The type of the custom resolver's input parameter. This can be a scalar, the name of an existing generated type, or a custom JSON schema object. If undefined, the resolver does not accept an input.

    • input_type_format string

      The kind of input type the custom resolver uses. This value must agree with the value of input_type:

      • A scalar input type must use "scalar" or "scalar-list"
      • A generated input type must use "generated" or "generated-list"
      • A custom input type must use "custom"

      If undefined, the resolver does not accept an input.

      Values are scalar, scalar-list, generated, generated-list, or custom.

    • payload_type string | object

      The type of the value returned by the custom resolver. This can be a scalar, the name of an existing generated type, or a custom JSON schema object.

      If undefined, the resolver returns a DefaultPayload object:

      type DefaultPayload {
        status: String!
      }
      
    • payload_type_format string

      The kind of payload type the custom resolver uses. This value must agree with the value of payload_type:

      • A scalar payload type must use "scalar" or "scalar-list"
      • A generated payload type must use "generated" or "generated-list"
      • A custom payload type must use "custom"

      If undefined, the resolver returns a DefaultPayload object.

      Values are scalar, scalar-list, generated, generated-list, or custom.

    • _id string

      The custom resolver's unique ID.

    • function_id string

      The resolver function's unique ID.

POST /groups/{groupId}/apps/{appId}/graphql/custom_resolvers
curl \
 --request POST 'https://services.cloud.mongodb.com/api/admin/v3.0/groups/{groupId}/apps/{appId}/graphql/custom_resolvers' \
 --header "Authorization: Bearer $ACCESS_TOKEN" \
 --header "Content-Type: application/json" \
 --data '{"on_type":"string","field_name":"string","input_type":"string","input_type_format":"scalar","payload_type":"string","payload_type_format":"scalar","_id":"string","function_id":"string"}'
Request examples
{
  "on_type": "string",
  "field_name": "string",
  "input_type": "string",
  "input_type_format": "scalar",
  "payload_type": "string",
  "payload_type_format": "scalar",
  "_id": "string",
  "function_id": "string"
}
Response examples (201)
{
  "on_type": "string",
  "field_name": "string",
  "input_type": "string",
  "input_type_format": "scalar",
  "payload_type": "string",
  "payload_type_format": "scalar",
  "_id": "string",
  "function_id": "string"
}