-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add responses payload for array types
- Loading branch information
1 parent
e27dc19
commit d92e16d
Showing
8 changed files
with
29 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
export * from './response.exception-filter' | ||
export * from './response.exception-filter' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
export * from './filters' | ||
export * from './interfaces' | ||
export * from './types' | ||
export * from './types' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
export * from './response-error.interface' | ||
export * from './response-payload.interface' | ||
export * from './response-filter-config.interface' | ||
export * from './response-filter-config.interface' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
export interface ResponseFilterConfig { | ||
stack?: boolean | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
import { ResponseError } from "./response-error.interface" | ||
import { ResponseError } from './response-error.interface' | ||
|
||
export interface ResponsePayload<T> { | ||
data?: T | ||
data?: T | T[] | ||
error?: ResponseError | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
export * from './response-error.type' | ||
export * from './response-payload.type' | ||
export * from './response-payload.type' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import { Type } from '@nestjs/common' | ||
import { Field, ObjectType } from '@nestjs/graphql' | ||
import { ResponseError } from '../interfaces/response-error.interface' | ||
import { ResponsePayload } from '../interfaces/response-payload.interface' | ||
import { ResponseErrorType } from './response-error.type' | ||
|
||
export const ResponsePayloadType = <T>( | ||
classRef: Type<T>, | ||
): Type<ResponsePayload<T>> => { | ||
@ObjectType('ResponsesPayload', { isAbstract: true }) | ||
class ResponsePayloadType implements ResponsePayload<T> { | ||
@Field(() => [classRef], { nullable: true }) | ||
data?: T[] | ||
|
||
@Field(() => ResponseErrorType, { nullable: true }) | ||
error?: ResponseError | ||
} | ||
|
||
return ResponsePayloadType | ||
} |