Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

407
Views
Query multiple fields with same value [GraphQL][Amplify]

I'm creating an API with AWS Amplify and AppSync GraphQL. I Work on a Tinder like App.

I would like to search the same value in two fields for a Query. I've tried a lot of solutions, but none seems to work.

I have a User @Model which is connected to many Match via @connection

type User @model
  @auth(rules: [{allow: public}])

    {
      id: ID!
      email: String!
      password: String
      age: String!
      name: String!
      description: String
      pickupLine: String
      orientation: Orientation!
      gender: Gender! 
      animal: Animal!
      profilePicture: String!
      pictures: [String]!
      location: Location
      numberOfSparksAvailable: Int!
      matchs: [Match]
        @connection(keyName: "byUser", fields: ["id"])
      sparks: [Spark]
        @connection(keyName: "byUser", fields: ["id"])
    }

And I have a Match @Model which have a senderId field and a receiverId field

type Match @model
  @auth(rules: [{allow: public}])
  
  @key(name: "byUser", fields: ["receiverId", "senderId"], queryField: "matchByUser")
  @key(name: "bySender", fields: ["senderId"], queryField: "sparkBySender")
  @key(name: "byReceiver", fields: ["receiverId"], queryField: "sparkByReceiver")
    {
      id: ID!
      status: MatchStatus!
      matchType: MatchType
      sender: User! @connection(fields: ["senderId"])
      senderId: ID!
      receiver: User! @connection(fields: ["receiverId"])
      receiverId: ID!
      answerFrom: Answer!
      answerTo: Answer
      chatRoomId: ID!
      chatRoom: ChatRoom!
        @connection(fields: ["chatRoomId"])
      deletedAt: AWSDate
    }

And and I don't find any way to make bySender @key look for both senderId and receiverId. I want to be able to have all the Matches for a User whether he's the receiver or the sender.

But when I make a Query to ListUsers I only get the Matches where the User is a receiver.

I've also tried to make multiple @connection but it is not allowed by Graphql-transformer.

I also tried to make an usersId: [ID!]! like that

type Match @model {
  ...
  usersId: [ID!]!
  users: [User!]!
    @connection(fields: ["usersId"])
  ...
}

But It's also not allowed by graphql-transformer..

Has anyone a solution to get all the matches for a User?

Thanks a lot !

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!