Returning multiple types as custom payload in a custom resolver

Hi!

I’m having trouble returning multiple types as a custom payload in my custom resolver. For instance, I am able to create a custom resolver that returns an array of objects, together with a boolean. However, if I want to return e.g an array of Documents, together with a boolean, I can’t find out how.

I have described the problem further in the following SO post:

Thanks in advance!

Can you paste your input and payload type? I was able to do this with a “Custom” payload type with the following schema:

{
  "bsonType": "object",
  "title": "FindShirts",

  "properties": {
    "shirts": {
      "bsonType": "array",
      "items": {
        "bsonType": "object",
        "title": "ShirtObject",
        "properties": {
          "size": {
            "bsonType": "string"
          }
        }
      }
    },
    "isFoo": {
      "bsonType": "boolean"
    }
  }
}

GraphiQL Schema -

image

Hi Sumedha! Thank you for the reply.

I’m sorry, I realize that my question wasn’t super clear (I will edit it after writing this comment).
I’m aware that I can configure objects in the way you do above, with custom fields defined within the schema. However, what I’m interested in doing is to link to an EXISTING schema.

Say that I’ve defined a shirt schema (1) already, with fields color and size. Then I want to define a separate schema (2), with a list of these shirt types, together with a boolean. This way, if I adjust the prior schema (1) and add a field “fabric”, I don’t have to add that field to my second schema (2) separately.

As I understand it, this is how it works when you create a Custom Resolver through the UI and pick the payload type “Existing Type (List)”. However, if I go with that approach, I cannot have my boolean in the payload.

4 Likes