Description
π Documentation
Hi @doug-martin , thanks a lot for this incredibly useful library!
I stumble against one issue here. I didn't find any documentation for it yet and I'm not sure if is possible or not to achieve this
Is it possible to based my filtering using nested relations (2,3, or more)?
Please watch the example below for a better understanding of my question
For example:
I have the following database relation:
Is there possible to query the appointment like this (query appointments based on user's id having the user in relation with the client and obviously client in relation with appointment):
query appointments {
appointments(filter: { client: { user: {id: { eq:"49082d78-c63c-4f2e-82e1-601d7ee5d6fe"}} }})
{ ... }
}
I can only query an appointment using the client id:
query appointments {
appointments(filter: { client: { id: { eq:"49082d78-c63c-4f2e-82e1-601d7ee5d6fe"} }})
{ ... }
}
Here is the code that I built so far:
appointemnt.model.ts
import {
FilterableField,
FilterableRelation,
} from '@nestjs-query/query-graphql';
import { ID, ObjectType } from '@nestjs/graphql';
import { ClientModel } from 'src/client/dto/client.model';
import { EmployeeModel } from 'src/employee/dto/employee.model';
@ObjectType('Appointment')
@FilterableRelation('client', () => ClientModel, {
disableRemove: true,
disableUpdate: true,
})
@FilterableRelation('employee', () => EmployeeModel, {
disableRemove: true,
disableUpdate: true,
})
export class AppointmentModel {
@FilterableField(() => ID)
id: string;
@FilterableField()
customClientPhone: string;
@FilterableField()
customClientName: string;
@FilterableField()
createdDateTime: Date;
@FilterableField()
startDateTime: string;
@FilterableField()
endDateTime: string;
@FilterableField()
canceledDateTime: string;
@FilterableField()
canceledReason: string;
}
client.model.ts
import {
FilterableField,
FilterableRelation,
} from '@nestjs-query/query-graphql';
import { Field, ID, ObjectType } from '@nestjs/graphql';
import { UserModel } from 'src/user/dto/user.model';
@ObjectType('Client')
@FilterableRelation('user', () => UserModel, {
disableRemove: true,
disableUpdate: true,
})
export class ClientModel {
@FilterableField(() => ID)
id: string;
}
user.model.ts
import { FilterableField } from '@nestjs-query/query-graphql';
import { Field, ID, ObjectType } from '@nestjs/graphql';
@ObjectType('User')
export class UserModel {
@FilterableField(() => ID)
id: string;
@FilterableField()
email: string;
@FilterableField()
firstName: string;
@FilterableField({ nullable: true })
lastName: string;
@FilterableField()
phone: string;
@Field({ nullable: true })
avatarLink: string;
}
Is it possible to query appointments based on the client's user model as described in the graphql query above?