Skip to content

GraphQL: How to query data from array of pointers #5894

Closed
@murshudov

Description

@murshudov

This is my query

query JobQuery {
  objects {
    getJob(objectId: "sqvJTrN9no") {
      title
      company {
        name
      }
      countries
    }
  }
}

and it returns

{
  "data": {
    "objects": {
      "getJob": {
        "title": "Sales Assistant",
        "company": {
          "name": "Gulfstream Distribution"
        },
        "countries": [
          {
            "__type": "Pointer",
            "className": "Country",
            "objectId": "lZ15JnGq7h"
          }
        ]
      }
    }
  }
}

But I want to get country details inside this query results. Is there a way to do that?

I thought maybe something like this exists:

query JobQuery {
  objects {
    getJob(objectId: "sqvJTrN9no") {
      title
      company {
        name
      }
      countries
    }
    
    findCountry(where: { objectId: { _in: ["lZ15JnGq7h"]} }) {
      results {
        name
      }
    }
  }
}

Result:

{
  "data": {
    "objects": {
      "getJob": {
        "title": "Sales Assistant",
        "company": {
          "name": "Gulfstream Distribution"
        },
        "countries": [
          {
            "__type": "Pointer",
            "className": "Country",
            "objectId": "lZ15JnGq7h"
          }
        ]
      },
      "findCountry": {
        "results": [
          {
            "name": "Azerbaijan"
          }
        ]
      }
    }
  }
}

I don't know how to include results from getJob query into findCountry query. Any help would be appreciated 😊

Metadata

Metadata

Assignees

No one assigned

    Labels

    type:featureNew feature or improvement of existing feature

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions