Skip to main content
The following examples are based on the following TodoItemDTO

ArgsTypes

QueryArgsType

Args type used in read endpoints to allow filtering, paging, and sorting. The QueryArgsType will generate an ArgsType that will require the user to provide three arguments.
  • filter? - A filter that should be used to find records to update. See FilterType
  • paging? - Options to page of result.
  • sorting? - Optional array to allow sorting of results. See SortType.

Usage


ObjectTypes

ConnectionType

Implementation of connections. Useful for large result sets where the end user should be able to page through the results.

Usage


UpdateManyResponseType

Response from updateMany mutations.

Usage


DeleteManyResponseType

Response from deleteMany mutations.

Usage


InputTypes

FilterType

GraphQL implementation of the @ptc-org/nestjs-query-core Filter type. The FilterType is dynamically created based on the fields in the DTO annotated with @FilterableField. Along with the dynamically create fields filter also has the following static fields:
  • and - Allows for joining multiple Filters with using an AND condition. For example, find all todo items that start with 'Foo' AND end in 'Bar'.
  • or - Allows for joining multiple Filters using an OR condition. For example, find all todo items that (are completed AND start with 'Foo') OR (are not completed and end in 'Bar').

SortType

The SortType allows you to sort results. NOTE This type is automatically created when using QueryArgsType. For more comprehensive examples take a look at the Sorting Docs

Fields

  • field - The field to sort on. The is an ENUM of @FilterableFields defined in the DTO.
  • direction - The direction to sort the field ASC or DESC.
  • nulls? - On supported storage engines you can specify the null sort order NULLS_FIRST, NULLS_LAST

CreateOneInputType

Input type for createOne mutations. NOTE Dont forget to annotate your DTO with @InputType() from @nestjs/graphql. NOTE Your DTO should be one that you want to use for input. For example you may not want to let the end user to specify the created or updated fields so you would create a new DTO just for input.

Usage


CreateManyInputType

Input type for createMany mutations. NOTE Dont forget to annotate your DTO with @InputType() from @nestjs/graphql. NOTE Your DTO should be one that you want to use for input. For example you may not want to let the end user to specify the created or updated fields so you would create a new DTO just for input.

Usage

UpdateOneInputType

InputType type for updateOne mutations. The UpdateOneInputType will generate an InputType that will require the user to provide two fields.
  • id - The id of the record to update
  • update - A record with fields to update.
Dont forget to annotate your DTO with @InputType() from @nestjs/graphql.
Your DTO should be one that you want to use for updates. For example you may not want to let the end user to update the created or updated fields so you would create a new DTO just for updates.

Usage


UpdateManyInputType

Input type for updateMany mutations. The UpdateOneInputType will generate an InputType that will require the user to provide two arguments.
  • filter - The filter that should be used to find records to update. See FilterType
  • update - The update to apply to each record found.
NOTE Dont forget to annotate your DTO with @InputType() from @nestjs/graphql. NOTE Your DTO should be one that you want to use for input. For example you may not want to let the end user to specify the created or updated fields so you would create a new DTO just for input.

Usage

In this example we use the read DTO for the FilterType, and a different update DTO.

DeleteOneInputType

InputType type for deleteOne mutations. The DeleteOneInputType will generate an InputType that will require the user to provide the id of the record to delete.

Usage


DeleteManyInputType

Input type type for deleteMany mutations. The DeleteManyInputType will generate an InputType that will require the user to provide:
  • filter - A filter used to find records to delete. See FilterType

Usage

Edit this page