GraphQLinq icon indicating copy to clipboard operation
GraphQLinq copied to clipboard

Array of required type in schema is not correctly maintained in queries

Open NoTuxNoBux opened this issue 2 years ago • 1 comments

Hello

I have a GraphQL schema that looks somewhat like this. (I abbreviated it for brevity, but it should still be mostly complete, it was automatically generated by Keystone 6, also known as Keystone Next):

type Query {
  sharedExperienceRooms(
    where: SharedExperienceRoomWhereInput! = {}
    orderBy: [SharedExperienceRoomOrderByInput!]! = []
    take: Int
    skip: Int! = 0
  ): [SharedExperienceRoom!]
}

type SharedExperienceRoom {
  id: ID!
  serverHost: String
}

input SharedExperienceRoomOrderByInput {
  id: OrderDirection
}

enum OrderDirection {
  asc
  desc
}

input SharedExperienceRoomWhereInput {
  id: IDFilter
}

input IDFilter {
  equals: ID
  in: [ID!]
  notIn: [ID!]
  lt: ID
  lte: ID
  gt: ID
  gte: ID
  not: IDFilter
}

I've then scaffolded the appropriate classes, and am the using the generated query context to do a query to fetch all items as follows:

var query = queryContext.SharedExperienceRooms(new SharedExperienceRoomWhereInput(), new List<SharedExperienceRoomOrderByInput>(), null, 0);

After that, I get the following query as output from GraphQLinq:

query (
  $where: SharedExperienceRoomWhereInput
  $orderBy: [SharedExperienceRoomOrderByInput]
  $skip: Int
) {
  result: sharedexperiencerooms(where: {}, orderBy: [], skip: 0) {
    id
  }
}

However, next to the issue from #15, this query contains $orderBy: [SharedExperienceRoomOrderByInput] instead of $orderBy: [SharedExperienceRoomOrderByInput!] (note the exclamation mark) from the original schema, which generates syntax errors on the side of the server.

NoTuxNoBux avatar Sep 14 '21 14:09 NoTuxNoBux

Blocked by #22

Giorgi avatar May 18 '22 20:05 Giorgi