Skip to content

abduljavedkhan/typeGraphQL-CRUD-API

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

TypeGraphQL-CRUD-API(in-progress)

What is TypeGraphQL ?

Steps to run the project

- Clone the repository
- update DB details on .env file
- Install the required dependency: `npm install`
- Run the project: `npm run start`

Technical Specification

Following stack has been used in the project

Output

- Retrieve Data:

passing input as tableName: "public.product" and getting payload object in response.

image

Passing tableName as "public.purchase_items"

image

Passing tableName as "public.users"

image

- Filtering:

Here, we have three types of filters: number, text or date. Each filter has its own subType.

- number filter

  1. subType: "greater than"

Execute below query to get Price value greater than 20

{
  payload(
    databaseId: 1
    tableName: "public.products"
    filter: {
      type: "number"
      columnName: "price"
      subType: "greater than"
      value: "20"
    }
  ) {
    id
    data
  }
}

Response

image

  1. subType: "less than"

Execute below query to get Payload having Price value less than 20

{
  payload(
    databaseId: 1
    tableName: "public.products"
    filter: {
      type: "number"
      columnName: "price"
      subType: "less than"
      value: "20"
    }
  ) {
    id
    data
  }
}

Response

image

  1. subType: "equal to"

Execute below query to get Payload having Price value equal to 108.00

{
  payload(
    databaseId: 1
    tableName: "public.products"
    filter: {
      type: "number"
      columnName: "price"
      subType: "equal to"
      value: "108.00"
    }
  ) {
    id
    data
  }
}

Response

image

- text filter

  1. subType: "equal to"
{
  payload(
    databaseId: 1
    tableName: "public.products"
    filter: {
      type: "text"
      columnName: "title"
      subType: "equal to"
      value: "Python Book"
    }
  ) {
    id
    data
  }
}

Response

image

  1. subType: "includes"
  payload(
    databaseId: 1
    tableName: "public.products"
    filter: {
      type: "text"
      columnName: "title"
      subType: "includes"
      value: "CD"
    }
  ) {
    id
    data
  }
}

Response

image

  1. subType: "starts with"
{
  payload(
    databaseId: 1
    tableName: "public.products"
    filter: {
      type: "text"
      columnName: "title"
      subType: "starts with"
      value: "Coloring"
    }
  ) {
    id
    data
  }
}

Response image

  1. subType: "ends with"
{
  payload(
    databaseId: 1
    tableName: "public.products"
    filter: {
      type: "text"
      columnName: "title"
      subType: "ends with"
      value: "Book"
    }
  ) {
    id
    data
  }
}

Response

image

- date filter

  1. subType: "before" pass value as date in YYYY-MM-DD format
{
  payload(
    databaseId: 1
    tableName: "public.products"
    filter: {
      type: "date"
      columnName: "created_at"
      subType: "before"
      value: "2021-01-02"
    }
  ) {
    id
    data
  }
}

Response

image

  1. subType: "after" pass value as date in YYYY-MM-DD format
{
  payload(
    databaseId: 1
    tableName: "public.products"
    filter: {
      type: "date"
      columnName: "created_at"
      subType: "after"
      value: "2021-01-20"
    }
  ) {
    id
    data
  }
}

Response

image

  1. subType: "is on"
{
  payload(
    databaseId: 1
    tableName: "public.products"
    filter: {
      type: "date"
      columnName: "created_at"
      subType: "is on"
      value: "2021-01-02"
    }
  ) {
    id
    data
  }
}

Response

image

  1. subType: "between" use dateFrom and dateTo input params
{
  payload(
    databaseId: 1
    tableName: "public.products"
    filter: {
      type: "date"
      columnName: "created_at"
      subType: "between"
      dateFrom:"2021-01-11", dateTo:"2021-01-20"
    }
  ) {
    id
    data
  }
}

Response

image

About

TypeScript based GraphQL API using TypeGraphQL framework.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors