How to compare two fields of same node while filtering in a graphql query?
Asked Answered
F

0

6

I have a model named as Student and want to filter out those students who have equal marks in physics and chemistry.The student schema is as follows.

type Student @model {
   name: String!
   physicsMarks: Int!
   chemistryMarks: Int!
   createdAt: DateTime!
   id: ID! @isUnique
   updatedAt: DateTime!
} 

We can compare a field with a value inside a query filter if we pass the value as an argument, but how to compare two fields of the same node while querying?

Here is the query with the missing filter I want to write.

query{
 allStudents(
  filter:{//??//}){
   id
   name
  }
}

Can we handle such cases using queries? Or we will have to write resolver functions for such cases.

Note:- I am using GraphCool's interface to define schema, permissions, resolver functions etc.

Froe answered 21/2, 2018 at 12:26 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.