signal is an interface and security rule needed to execute the service function inside the server, and a way to resolve the data. The interface defined in the signal is used to create an endpoint in the server module, and to create the type of the fetch function in the client module. In addition, it provides various convenience functions for easy and performance-oriented query/management of data.
The type of the signal endpoint can be declared in various ways based on various web technologies. Generally, Restful API, websocket, queue, pubsub, etc. are used to declare the data exchange method.
1.1. @Query & @Mutation
1.1.1. Query(GET) and Mutation(POST) endpoints
import { LogSignal, Query, Signal, resolve } from '@core/base';
import { Srvs, cnst } from '../cnst';
@Signal({ name: 'MySignal', prefix: 'mySignal' })
export class MySignal extends LogSignal(Srvs) {
@Query.Public(() => [cnst.Drone])
async getAnyDrones() {
const drones = await this.droneSerivce.listAny(); // db.Drone[]
return resolve<cnst.Drone[]>(drones);
}
}
1.1.2. Signal endpoint options
Option | Type | Default | Description | Example |
---|
nullable | boolean | false | 데이터가 null인 경우를 허용할지 여부, 기본적으로 null인 경우 api 에러가 발생함. | @Query.Public(() => cnst.Drone, { nullable: true })
async findDrone() {
const drone = await this.droneSerivce.findAny(); // db.Drone | null
return resolve<cnst.Drone | null>(drone);
}
// const drone = fetch.findDrone(); // cnst.Drone | null
|
nullable:boolean:false
데이터가 null인 경우를 허용할지 여부, 기본적으로 null인 경우 api 에러가 발생함.
@Query.Public(() => cnst.Drone, { nullable: true })
async findDrone() {
const drone = await this.droneSerivce.findAny(); // db.Drone | null
return resolve<cnst.Drone | null>(drone);
}
// const drone = fetch.findDrone(); // cnst.Drone | null
1.1.3. External Arguments
A decorator that handles parameters from incoming requests.
• Arg.Param
@Query.Public(() => cnst.Drone)
async getDroneById(
@Arg.Param("droneId", () => ID) droneId: string
) {
const drone = await this.droneSerivce.getDrone(droneId);
return resolve<cnst.Drone>(drone);
}
1.1.4. Internal Arguments
A decorator that handles parameters from internal requests.
1.2. @Message & @Pubsub
1.2.1. Websocket message protocols
A protocol used for real-time bidirectional communication through WebSocket.
1.2.2. Websocket endpoint options
Various options that can be set on the WebSocket endpoint.
1.2.3. Websocket external arguments
A decorator that handles parameters from external requests.
1.2.4. Websocket internal arguments
A decorator that handles parameters from internal requests.
1.3. @Process
1.3.1. Queue job protocols
A protocol used for asynchronous job processing through a queue.
1.3.2. Queue job options
Various options that can be set on the queue job.
1.3.3. Queue external arguments
A decorator that handles parameters from external requests.
1.3.4. Queue internal arguments
A decorator that handles parameters from internal requests.
1.4. @ResolveField
Defines a method to dynamically resolve GraphQL fields.
2.1. GraphQL fetch
Defines a method to fetch data using GraphQL.
2.2. RestAPI fetch
Defines a method to fetch data using REST API.
2.3. Socket.io fetch
Defines a method to fetch data using Socket.io.
3.1. Slice pattern for client
Describes the slice pattern used in the client.
3.2. Slicing model paginations
Describes the slicing technique for model pagination.
4.1. Predefined Guard Types
Describes the predefined guard types and their usage.
4.2. Custom guarding endpoints
Defines a method to customize guards for each service to control endpoint access.
Opens an endpoint from the outside and validates the request through the GraphQL protocol. If there is no problem, it is passed to the Service that can handle the business logic. The signal file unifies the request-response rule using the common backend and frontend.
field | Description |
---|
model | 데이터 Full Model 1개를 조회 시 사용 |
modelList | 데이터 여러 개를 조회 시 사용, query, sort, limit등을 설정 |
modelInsight | 데이터 쿼리에 대한 인사이트 (전체 개수 등)를 제공 |
createModel | 데이터 생성 시 사용 |
updateModel | 데이터 수정 시 사용 |
removeModel | 데이터 삭제 시 사용 |
model
데이터 Full Model 1개를 조회 시 사용
modelList
데이터 여러 개를 조회 시 사용, query, sort, limit등을 설정
modelInsight
데이터 쿼리에 대한 인사이트 (전체 개수 등)를 제공
The fetch structure in the client is defined to communicate with the backend using the urql/core library. In addition, the graphql querystring is automatically written through the model.signal.ts file.
method | Description |
---|
initModel | 데이터를 초기에 불러올 때 사용, 초기 query, sort, limit등을 설정, 서버사이드에서 데이터를 클라이언트 단으로 제공할 수 있는 형태로 반환 |
viewModel | 데이터 Full Model 1개를 조회 시 사용, 서버사이드에서 데이터를 클라이언트 단으로 제공할 수 있는 형태로 반환 |
model | 데이터 Full Model 1개를 조회 시 사용 |
modelList | 데이터 여러 개를 조회 시 사용, query, sort, limit등을 설정 |
modelInsight | 데이터 쿼리에 대한 인사이트 (전체 개수 등)를 제공 |
createModel | 데이터 생성 시 사용 |
updateModel | 데이터 수정 시 사용 |
removeModel | 데이터 삭제 시 사용 |
initModel
데이터를 초기에 불러올 때 사용, 초기 query, sort, limit등을 설정, 서버사이드에서 데이터를 클라이언트 단으로 제공할 수 있는 형태로 반환
viewModel
데이터 Full Model 1개를 조회 시 사용, 서버사이드에서 데이터를 클라이언트 단으로 제공할 수 있는 형태로 반환
model
데이터 Full Model 1개를 조회 시 사용
modelList
데이터 여러 개를 조회 시 사용, query, sort, limit등을 설정
modelInsight
데이터 쿼리에 대한 인사이트 (전체 개수 등)를 제공