2

I have this query (in Hasura in case that matters):

query MyQuery {
  records(distinct_on:[recordId],   where: { modelId: {_eq: "2f1f70b8-cb7b-487c-9e4c-ca03624ce926"}}) {
    recordId
    inboundEdges(where: {fromModelId: {_eq: "f0e19461-6d38-4148-8041-54eba6451293"}}) {
      fromRecord {
        property_path_values(where:{stringValue:{_eq:"2021-08-26"}}) {
          stringValue
        }
      }
    }
  }
}

I get this result back:

{
  "data": {
    "records": [
      {
        "recordId": "2fbe37b1-78db-4b22-b713-2388cfb52597",
        "inboundEdges": [
          {
            "fromRecord": {
              "property_path_values": [
                {
                  "stringValue": "2021-08-26"
                }
              ]
            }
          },
          {
            "fromRecord": {
              "property_path_values": [
                {
                  "stringValue": "2021-08-26"
                },
                {
                  "stringValue": "2021-08-26"
                }
              ]
            }
          }
        ]
      },
      {
        "recordId": "7b34e85d-f4e1-4099-89d9-02483128a6cd",
        "inboundEdges": [
          {
            "fromRecord": {
              "property_path_values": [
                {
                  "stringValue": "2021-08-26"
                }
              ]
            }
          }
        ]
      },
      {
        "recordId": "840f52e2-0f2e-4591-810d-19f9e8840a49",
        "inboundEdges": []
      }
    ]
  }
}

I do not want the third result in the response, because it's inboundEdges array is empty.

What I am trying to say is: find me all records that have at least one inboundEdge with a fromRecord that has at least one property_path_value with a stringValue equal to 2021-08-26. I do not want to have to parse the response needing to exclude results with inboundEdges === []

1 Answer 1

1

Seems I was confusing the selection set with the place to state the query. The right way to do what I wanted is:

query MyQuery {
  records(where: {inboundEdges: {fromModelId: {_eq: "f0e19461-6d38-4148-8041-54eba6451293"}, fromRecord: {propertyPathValues: {stringValue: {_eq: "2021-08-26"}}}}, modelId: {_eq: "2f1f70b8-cb7b-487c-9e4c-ca03624ce926"}}) {
    recordId
  }
}

i.e. put the query in the where clause, not the selection set

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.