How to add column to junction table in Graphql

Currently I have Student and Course Table in 1-n relationship

tables:

  1. Student
  2. course_students
  3. Course

Right now, I can get Students under Course using findCourseByID in Graphql

query{
  findCourseByID(id:""){
    _id
    students{
      data{
        name
      }
    }
  }
}

But if I add a status in course_students table, it is not able to get those record and doing some filtering

For example, add kicked in to course_students, how can i filtered out or how can i print the status out like using

query{
  findCourseByID(id:"298585098922492417"){
    _id
    students{
      data{
        name
       kicked
      }
    }
  }
} 

I can able to do this in FQL but i am not sure is there any easier way in Graphql

Hi @dominwong4 . Unfortunately, the GraphQL API does not include sorting out of the box. Here is an open feature request for it.

https://forums.fauna.com/t/filtering-in-autogenerated-graphql-queries/64

To do this with GraphQL, the best thing might be to create a custom resolver, something like

type Query {
  findStudentsByCourseAndStatus(id: ID!, status: String!): [Student!] @resolver
}

It’s not a great workaround, but it is possible. There is also a feature request to include resolvers at the user type level. This would let us add special sorting/filtering options at lower levels that would let us use a pattern like findCourseByID -> students(<sort and filter args>) which is definitely the more graphql-canonical way to do it.

https://forums.fauna.com/t/allow-resolver-directive-in-user-defined-types-fields/31