Skip to content

Function: Args()

Call Signature

ts
function Args(): ParameterDecorator;

Defined in: packages/apollo/src/decorators/args.decorator.ts:128

Decorator for resolver arguments.

Returns

ParameterDecorator

Example

typescript
@Query()
async user(@Args('id') id: string) { }

@Query()
async users(@Args('limit') limit: number, @Args('offset') offset: number) { }

@Mutation()
async createUser(
  @Args({ name: 'input', type: () => CreateUserInput, description: 'User input' })
  input: CreateUserInput
) { }

@Query()
async search(
  @Args({ name: 'query', nullable: true, defaultValue: '' })
  query: string
) { }

Call Signature

ts
function Args(name): ParameterDecorator;

Defined in: packages/apollo/src/decorators/args.decorator.ts:129

Decorator for resolver arguments.

Parameters

ParameterType
namestring

Returns

ParameterDecorator

Example

typescript
@Query()
async user(@Args('id') id: string) { }

@Query()
async users(@Args('limit') limit: number, @Args('offset') offset: number) { }

@Mutation()
async createUser(
  @Args({ name: 'input', type: () => CreateUserInput, description: 'User input' })
  input: CreateUserInput
) { }

@Query()
async search(
  @Args({ name: 'query', nullable: true, defaultValue: '' })
  query: string
) { }

Call Signature

ts
function Args(options): ParameterDecorator;

Defined in: packages/apollo/src/decorators/args.decorator.ts:130

Decorator for resolver arguments.

Parameters

ParameterType
optionsArgsOptions

Returns

ParameterDecorator

Example

typescript
@Query()
async user(@Args('id') id: string) { }

@Query()
async users(@Args('limit') limit: number, @Args('offset') offset: number) { }

@Mutation()
async createUser(
  @Args({ name: 'input', type: () => CreateUserInput, description: 'User input' })
  input: CreateUserInput
) { }

@Query()
async search(
  @Args({ name: 'query', nullable: true, defaultValue: '' })
  query: string
) { }

Call Signature

ts
function Args(name, options): ParameterDecorator;

Defined in: packages/apollo/src/decorators/args.decorator.ts:131

Decorator for resolver arguments.

Parameters

ParameterType
namestring
optionsOmit<ArgsOptions, "name">

Returns

ParameterDecorator

Example

typescript
@Query()
async user(@Args('id') id: string) { }

@Query()
async users(@Args('limit') limit: number, @Args('offset') offset: number) { }

@Mutation()
async createUser(
  @Args({ name: 'input', type: () => CreateUserInput, description: 'User input' })
  input: CreateUserInput
) { }

@Query()
async search(
  @Args({ name: 'query', nullable: true, defaultValue: '' })
  query: string
) { }

Released under the MIT License.