Unexpected Postgraphile query docs

Unexpected Postgraphile query docs


0

I have Postgraphile running and exploring the queries. Based on my schema.prisma, I expected to run a GraphQL query similar to the SQL query below. Why do the Postgraphile
queries in the docs appear differently than the GraphQL official docs? How do I proceed to build a GraphQL query?

SQL query

select * 
from "Shift" s 
join "Facility" f on s.facility_id = f.id 
  and f.is_active = true -- Facility active
join "Worker" w on w.id = 2
  and w.is_active = true
  and w.profession = s.profession -- Shift and Worker profession match
left join "DocumentWorker" dw on dw.worker_id = w.id -- Worker has document
left join "FacilityRequirement" fr on fr.facility_id = f.id 
  and fr.document_id = dw.document_id -- Facility requires document
where s.is_deleted = false -- Shift is not deleted and not claimed
  and s.worker_id is null 

I am unable to run this GraphQL query that I was expecting to be based on the GraphQL docs:

  shifts(
    where: {
      isDeleted: false,              # Shift is not deleted and not claimed
      worker: { id: null },          # Shift has no worker assigned
      facility: { isActive: true },  # Facility is active
    }
  ) {
    id
    start
    end
    profession
    facility {
      id
      name
    }
    worker {
      id
      name
      isActive
      profession
      documentWorkers {
        document {
          id
          name
        }
      }
    }
  }
}

schema.prisma

enum Profession {
  CNA
  LVN
  RN
}

model Worker {
  id         Int              @id @default(autoincrement())
  name       String
  is_active  Boolean          @default(false)
  profession Profession
  shifts     Shift[]
  documents  DocumentWorker[]
}

model Facility {
  id           Int                   @id @default(autoincrement())
  name         String
  is_active    Boolean               @default(false)
  requirements FacilityRequirement[]
  shifts       Shift[]
}

model Document {
  id           Int                   @id @default(autoincrement())
  name         String
  is_active    Boolean               @default(false)
  requirements FacilityRequirement[]
  workers      DocumentWorker[]
}

model FacilityRequirement {
  id          Int      @id @default(autoincrement())
  facility_id Int
  document_id Int
  facility    Facility @relation(fields: [facility_id], references: [id])
  document    Document @relation(fields: [document_id], references: [id])
}

model DocumentWorker {
  id          Int      @id @default(autoincrement())
  worker_id   Int
  document_id Int
  worker      Worker   @relation(fields: [worker_id], references: [id])
  document    Document @relation(fields: [document_id], references: [id])
}

model Shift {
  id          Int        @id @default(autoincrement())
  start       DateTime
  end         DateTime
  profession  Profession
  is_deleted  Boolean    @default(false)
  facility_id Int
  worker_id   Int?
  worker      Worker?    @relation(fields: [worker_id], references: [id])
  facility    Facility   @relation(fields: [facility_id], references: [id])
}

query docs

allDocuments(
after: Cursor
before: Cursor
condition: DocumentCondition
first: Int
last: Int
offset: Int
orderBy: [DocumentsOrderBy!] = [PRIMARY_KEY_ASC]
): DocumentsConnection
Reads and enables pagination through a set of Document.

allDocumentWorkers(
after: Cursor
before: Cursor
condition: DocumentWorkerCondition
first: Int
last: Int
offset: Int
orderBy: [DocumentWorkersOrderBy!] = [PRIMARY_KEY_ASC]
): DocumentWorkersConnection
Reads and enables pagination through a set of DocumentWorker.

allFacilities(
after: Cursor
before: Cursor
condition: FacilityCondition
first: Int
last: Int
offset: Int
orderBy: [FacilitiesOrderBy!] = [PRIMARY_KEY_ASC]
): FacilitiesConnection
Reads and enables pagination through a set of Facility.

allFacilityRequirements(
after: Cursor
before: Cursor
condition: FacilityRequirementCondition
first: Int
last: Int
offset: Int
orderBy: [FacilityRequirementsOrderBy!] = [PRIMARY_KEY_ASC]
): FacilityRequirementsConnection
Reads and enables pagination through a set of FacilityRequirement.

allShifts(
after: Cursor
before: Cursor
condition: ShiftCondition
first: Int
last: Int
offset: Int
orderBy: [ShiftsOrderBy!] = [PRIMARY_KEY_ASC]
): ShiftsConnection
Reads and enables pagination through a set of Shift.

allWorkers(
after: Cursor
before: Cursor
condition: WorkerCondition
first: Int
last: Int
offset: Int
orderBy: [WorkersOrderBy!] = [PRIMARY_KEY_ASC]
): WorkersConnection
Reads and enables pagination through a set of Worker.

allPrismaMigrations(
after: Cursor
before: Cursor
condition: _PrismaMigrationCondition
first: Int
last: Int
offset: Int
orderBy: [_PrismaMigrationsOrderBy!] = [PRIMARY_KEY_ASC]
): _PrismaMigrationsConnection
Reads and enables pagination through a set of _PrismaMigration.

documentById(id: Int!): Document
documentWorkerById(id: Int!): DocumentWorker
facilityById(id: Int!): Facility
facilityRequirementById(id: Int!): FacilityRequirement
shiftById(id: Int!): Shift
workerById(id: Int!): Worker
_prismaMigrationById(id: String!): _PrismaMigration
document(nodeId: ID!): Document
Reads a single Document using its globally unique ID.

documentWorker(nodeId: ID!): DocumentWorker
Reads a single DocumentWorker using its globally unique ID.

facility(nodeId: ID!): Facility
Reads a single Facility using its globally unique ID.

facilityRequirement(nodeId: ID!): FacilityRequirement
Reads a single FacilityRequirement using its globally unique ID.

shift(nodeId: ID!): Shift
Reads a single Shift using its globally unique ID.

worker(nodeId: ID!): Worker
Reads a single Worker using its globally unique ID.

_prismaMigration(nodeId: ID!): _PrismaMigration
Reads a single _PrismaMigration using its globally unique ID.


Load 5 more related questions


Show fewer related questions

0



Leave a Reply

Your email address will not be published. Required fields are marked *