Skip to content
This repository has been archived by the owner on Nov 15, 2021. It is now read-only.

Commit

Permalink
Add NonNullGraphType
Browse files Browse the repository at this point in the history
  • Loading branch information
phamhongphuc authored and sawakisei committed May 22, 2019
1 parent b520c13 commit 1e3601f
Show file tree
Hide file tree
Showing 5 changed files with 92 additions and 38 deletions.
4 changes: 2 additions & 2 deletions uit.hotel.client/graphql/schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -568,7 +568,7 @@ type Floor {
name: String!

# Danh sách các phòng có trong tầng
rooms: [Room]
rooms: [Room!]!
}

input FloorCreateInput {
Expand Down Expand Up @@ -1088,7 +1088,7 @@ input ReceiptCreateInput {
# Một phòng trong khách sạn
type Room {
# Danh sách thông tin thuê phòng
bookings: [Booking]
bookings: [Booking!]!

# Đơn đặt phòng hiện tại
currentBooking(from: DateTimeOffset!, to: DateTimeOffset!): Booking
Expand Down
32 changes: 24 additions & 8 deletions uit.hotel.client/graphql/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -2436,12 +2436,20 @@
"description": "Danh sách thông tin thuê phòng",
"args": [],
"type": {
"kind": "LIST",
"kind": "NON_NULL",
"name": null,
"ofType": {
"kind": "OBJECT",
"name": "Booking",
"ofType": null
"kind": "LIST",
"name": null,
"ofType": {
"kind": "NON_NULL",
"name": null,
"ofType": {
"kind": "OBJECT",
"name": "Booking",
"ofType": null
}
}
}
},
"isDeprecated": false,
Expand Down Expand Up @@ -2677,12 +2685,20 @@
"description": "Danh sách các phòng có trong tầng",
"args": [],
"type": {
"kind": "LIST",
"kind": "NON_NULL",
"name": null,
"ofType": {
"kind": "OBJECT",
"name": "Room",
"ofType": null
"kind": "LIST",
"name": null,
"ofType": {
"kind": "NON_NULL",
"name": null,
"ofType": {
"kind": "OBJECT",
"name": "Room",
"ofType": null
}
}
}
},
"isDeprecated": false,
Expand Down
90 changes: 64 additions & 26 deletions uit.hotel.client/graphql/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -706,7 +706,7 @@ export type Floor = {
/** Tên tầng */
name: Scalars['String'];
/** Danh sách các phòng có trong tầng */
rooms: Maybe<Array<Maybe<Room>>>;
rooms: Array<Room>;
};

export type FloorCreateInput = {
Expand Down Expand Up @@ -1091,7 +1091,7 @@ export type ReceiptCreateInput = {
/** Một phòng trong khách sạn */
export type Room = {
/** Danh sách thông tin thuê phòng */
bookings: Maybe<Array<Maybe<Booking>>>;
bookings: Array<Booking>;
/** Đơn đặt phòng hiện tại */
currentBooking: Maybe<Booking>;
/** Phòng thuộc tầng nào */
Expand Down Expand Up @@ -1608,14 +1608,10 @@ export type GetFloorsQueryVariables = {};
export type GetFloorsQuery = {
floors: Array<
Pick<Floor, 'id' | 'name' | 'isActive'> & {
rooms: Maybe<
Array<
Maybe<
Pick<Room, 'id' | 'name' | 'isActive'> & {
roomKind: Pick<RoomKind, 'id' | 'name'>;
}
>
>
rooms: Array<
Pick<Room, 'id' | 'name' | 'isActive'> & {
roomKind: Pick<RoomKind, 'id' | 'name'>;
}
>;
}
>;
Expand All @@ -1629,15 +1625,35 @@ export type GetFloorsMapQueryVariables = {
export type GetFloorsMapQuery = {
floors: Array<
Pick<Floor, 'id' | 'name' | 'isActive'> & {
rooms: Maybe<
Array<
Maybe<
Pick<Room, 'id' | 'name' | 'isActive'> & {
currentBooking: Maybe<Pick<Booking, 'id'>>;
roomKind: Pick<RoomKind, 'id' | 'name'>;
}
>
>
rooms: Array<
Pick<Room, 'id' | 'name' | 'isActive'> & {
currentBooking: Maybe<Pick<Booking, 'id'>>;
roomKind: Pick<RoomKind, 'id' | 'name'>;
}
>;
}
>;
};

export type GetTimelineQueryVariables = {};

export type GetTimelineQuery = {
floors: Array<
Pick<Floor, 'id' | 'name' | 'isActive'> & {
rooms: Array<
Pick<Room, 'id' | 'name' | 'isActive'> & {
bookings: Array<
Pick<
Booking,
| 'id'
| 'status'
| 'createTime'
| 'bookCheckInTime'
| 'bookCheckOutTime'
> & { patrons: Array<Maybe<Pick<Patron, 'id'>>> }
>;
roomKind: Pick<RoomKind, 'id' | 'name'>;
}
>;
}
>;
Expand Down Expand Up @@ -2155,10 +2171,10 @@ export namespace GetFloors {
export type Query = GetFloorsQuery;
export type Floors = NonNullable<GetFloorsQuery['floors'][0]>;
export type Rooms = NonNullable<
(NonNullable<(NonNullable<GetFloorsQuery['floors'][0]>)['rooms']>)[0]
(NonNullable<GetFloorsQuery['floors'][0]>)['rooms'][0]
>;
export type RoomKind = (NonNullable<
(NonNullable<(NonNullable<GetFloorsQuery['floors'][0]>)['rooms']>)[0]
(NonNullable<GetFloorsQuery['floors'][0]>)['rooms'][0]
>)['roomKind'];
}

Expand All @@ -2167,17 +2183,39 @@ export namespace GetFloorsMap {
export type Query = GetFloorsMapQuery;
export type Floors = NonNullable<GetFloorsMapQuery['floors'][0]>;
export type Rooms = NonNullable<
(NonNullable<(NonNullable<GetFloorsMapQuery['floors'][0]>)['rooms']>)[0]
(NonNullable<GetFloorsMapQuery['floors'][0]>)['rooms'][0]
>;
export type CurrentBooking = NonNullable<
(NonNullable<
(NonNullable<
(NonNullable<GetFloorsMapQuery['floors'][0]>)['rooms']
>)[0]
(NonNullable<GetFloorsMapQuery['floors'][0]>)['rooms'][0]
>)['currentBooking']
>;
export type RoomKind = (NonNullable<
(NonNullable<(NonNullable<GetFloorsMapQuery['floors'][0]>)['rooms']>)[0]
(NonNullable<GetFloorsMapQuery['floors'][0]>)['rooms'][0]
>)['roomKind'];
}

export namespace GetTimeline {
export type Variables = GetTimelineQueryVariables;
export type Query = GetTimelineQuery;
export type Floors = NonNullable<GetTimelineQuery['floors'][0]>;
export type Rooms = NonNullable<
(NonNullable<GetTimelineQuery['floors'][0]>)['rooms'][0]
>;
export type Bookings = NonNullable<
(NonNullable<
(NonNullable<GetTimelineQuery['floors'][0]>)['rooms'][0]
>)['bookings'][0]
>;
export type Patrons = NonNullable<
(NonNullable<
(NonNullable<
(NonNullable<GetTimelineQuery['floors'][0]>)['rooms'][0]
>)['bookings'][0]
>)['patrons'][0]
>;
export type RoomKind = (NonNullable<
(NonNullable<GetTimelineQuery['floors'][0]>)['rooms'][0]
>)['roomKind'];
}

Expand Down
2 changes: 1 addition & 1 deletion uit.hotel/ObjectTypes/FloorType.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public FloorType()
Field(x => x.Id).Description("Id của tầng");
Field(x => x.Name).Description("Tên tầng");
Field(x => x.IsActive).Description("Trạng thái hoạt động");
Field<ListGraphType<RoomType>>(
Field<NonNullGraphType<ListGraphType<NonNullGraphType<RoomType>>>>(
nameof(Floor.Rooms),
"Danh sách các phòng có trong tầng",
resolve: context => context.Source.Rooms.ToList());
Expand Down
2 changes: 1 addition & 1 deletion uit.hotel/ObjectTypes/RoomType.cs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public RoomType()
"Loại phòng của phòng",
resolve: context => context.Source.RoomKind);

Field<ListGraphType<BookingType>>(
Field<NonNullGraphType<ListGraphType<NonNullGraphType<BookingType>>>>(
nameof(Room.Bookings),
"Danh sách thông tin thuê phòng",
resolve: context => context.Source.Bookings.ToList());
Expand Down

0 comments on commit 1e3601f

Please sign in to comment.