0

I'm trying to filter results based on the id of a child on graphql and receiving the following error:

"Expected JSON object for '$[filter]' but got a 'STRING' instead."

Most of the code was generated by aws amplify.

Schema

type Company {
    id: ID!
    name: String!
    disabled: Int
}

type Customer {
    id: ID!
    name: String!
    company: Company!
    disabled: Int
}

input ModelCustomerFilterInput {
    id: ModelIDFilterInput
    name: ModelStringFilterInput
    disabled: ModelIntFilterInput
    company: ModelCompanyFilterInput #added by me
    and: [ModelCustomerFilterInput]
    or: [ModelCustomerFilterInput]
    not: ModelCustomerFilterInput
}

input ModelCompanyFilterInput {
    id: ModelIDFilterInput
    name: ModelStringFilterInput
    disabled: ModelIntFilterInput
    and: [ModelCompanyFilterInput]
    or: [ModelCompanyFilterInput]
    not: ModelCompanyFilterInput
}

Query

query ListCustomers($filter: ModelCustomerFilterInput, $limit: Int, $nextToken: String) {
  listCustomers(filter: $filter, limit: $limit, nextToken: $nextToken) {
    __typename
    items {
      __typename
      id
      name
      company {
        __typename
        id
        name
        disabled
      }
      disabled
    }
    nextToken
  }
}

{"filter": {"company": {"id": {"eq": "example"}}}}
3
  • Where is the request being made? If it's on a frontend somewhere is the content-type set to application/json? Commented Nov 3, 2019 at 16:50
  • Directly on the aws appsync console. But it gives the same error on angular 8. Commented Nov 3, 2019 at 17:47
  • Did you see the response on forums.aws.amazon.com/thread.jspa?messageID=922391 ? Commented Nov 5, 2019 at 20:29

1 Answer 1

1

Already solved my problem.

What I did was change the schema itself in a way that company contains customers. In fact the problem was poor design of the schema.

I would really like to see a lookup function in graphql, but probably it wasnt designed for it.

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.