saurabh kumar
saurabh kumar

Reputation: 61

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

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.

Upvotes: 6

Views: 740

Answers (0)

Related Questions