moderate-tomatoM
Refine2y ago
11 replies
moderate-tomato

Modify graphql request format for KeystoneJS server

I'm using KeystoneJS for my backend stack, which includes a graphql schema that has a query like this:
type Query {
  users(where: UserWhereInput! = {}, orderBy: [UserOrderByInput!]! = [], take: Int, skip: Int! = 0, cursor: UserWhereUniqueInput): [User!]
  user(where: UserWhereUniqueInput!): User
  usersCount(where: UserWhereInput! = {}): Int
  buildings(where: BuildingWhereInput! = {}, orderBy: [BuildingOrderByInput!]! = [], take: Int, skip: Int! = 0, cursor: BuildingWhereUniqueInput): [Building!]
  building(where: BuildingWhereUniqueInput!): Building
  buildingsCount(where: BuildingWhereInput! = {}): Int
  units(where: UnitWhereInput! = {}, orderBy: [UnitOrderByInput!]! = [], take: Int, skip: Int! = 0, cursor: UnitWhereUniqueInput): [Unit!]
  unit(where: UnitWhereUniqueInput!): Unit
  unitsCount(where: UnitWhereInput! = {}): Int
  tags(where: TagWhereInput! = {}, orderBy: [TagOrderByInput!]! = [], take: Int, skip: Int! = 0, cursor: TagWhereUniqueInput): [Tag!]
  tag(where: TagWhereUniqueInput!): Tag
  tagsCount(where: TagWhereInput! = {}): Int
  keystone: KeystoneMeta!
  authenticatedItem: AuthenticatedItem
}

Where the BuildingOrderByInput type is this:
input BuildingOrderByInput {
  id: OrderDirection
  companyName: OrderDirection
  companyPhone: OrderDirection
  streetAddress1: OrderDirection
  streetAddress2: OrderDirection
  city: OrderDirection
  state: OrderDirection
  poBox: OrderDirection
  postalCode: OrderDirection
  country: OrderDirection
  createdAt: OrderDirection
}


I'm using the useDataGrid method from the Material UI integration, which uses a format for graphql queries that includes built-in query variables like sort, start, and limit to list records. Is there a way to change the variable names in the Refine app to match the query variables that my graphql server recognizes?
Was this page helpful?