Git Product home page Git Product logo

typescript-graphql's Introduction

This is an image ExpressJS Prisma GraphQL Typescript

Simple GraphQL api implementation.

Simple GraphQL implementation, built using GraphQL, Prisma ORM, Typescript And ExpressJS.

Instalations

installing the dependencies:

$ npm install

push prisma schema to database:

$ npx prisma db push

with building:

$ npm run build
$ npm start

or without building:

$ npm run dev

Usage

Open http://localhost:yourport/graphql in your browser and creating a new user and profile data

mutation {
  createUsers(
    userInputs: {
      firstName: "Shina" 
      lastName: "Mahiru" 
      gender: "Female" 
      dateOfBirth: "2003-12-05" 
      emailAddress: "[email protected]" 
      password: "Password" 
    }
  ){
    ##your selected fileds. for example:
    email_address
    profile {
      first_name
      last_name
    }
  }
}

Getting all users data:

query {
  ## your queries name. for example: 
  users {
    ## select the fields you want. for example
    user_id
    email_address
  }
}

and server will be give a responses:

{
  "data": {
    "users": [
      {
        "user_id": "3",
        "email_address": "[email protected]",
      },
      {
        "user_id": "4",
        "email_address": "[email protected]",
      },
      {
        "user_id": "5",
        "email_address": "[email protected]",
      }
    ]
  }
}

Getting all users data with profile:

query {
  ## your queries name. for example: 
  users {
    ## select the fields you want. for example
    user_id
    email_address
    profile {
      first_name
      last_name
      gender
    }
  }
}

server will give a responses:

{
  "data": {
    "users": [
      {
        "user_id": "3",
        "email_address": "[email protected]",
        "profile": {
          "first_name": "Shina",
          "last_name": "Mahiru",
          "gender": "Female"
        }
      },
      {
        "user_id": "4",
        "email_address": "[email protected]",
        "profile": {
          "first_name": "Tachibana",
          "last_name": "Kanade",
          "gender": "Female"
        }
      },
      {
        "user_id": "5",
        "email_address": "[email protected]",
        "profile": {
          "first_name": "Kagari",
          "last_name": "Ayaka",
          "gender": "Female"
        }
      }
    ]
  }
}

Get user by id with profile

mutation {
  findUserById(
    userInputs: { user_id : 3}
  ){
    ## select the fields you want. for example
    email_address
    profile {
      first_name
      last_name
      last_updated
    }
  }
}

server will give a response:

{
  "data": {
    "findUserById": {
      "email_address": "[email protected]",
      "profile": {
        "first_name": "Shina",
        "last_name": "Mahiru",
        "last_updated": "2023-01-31T03:27:53.217Z"
      }
    }
  }
}

Get profiles data with the user:

query {
  ## your queries name. for example: 
  profiles {
    ## select the fields you want. for example
    first_name
    last_name
    gender
    last_updated
    user {
      email_address
      created_at
    }
  }
}

server will give a response:

{
  "data": {
    "profiles": [
      {
        "first_name": "Shina",
        "last_name": "Mahiru",
        "gender": "Female",
        "last_updated": "2023-01-31T03:27:53.217Z",
        "user": {
          "email_address": "[email protected]",
          "created_at": "2023-01-31T03:27:53.217Z"
        }
      },
      {
        "first_name": "Tachibana",
        "last_name": "Kanade",
        "gender": "Female",
        "last_updated": "2023-01-31T04:19:07.267Z",
        "user": {
          "email_address": "[email protected]",
          "created_at": "2023-01-31T04:19:07.267Z"
        }
      },
      {
        "first_name": "Kagari",
        "last_name": "Ayaka",
        "gender": "Female",
        "last_updated": "2023-01-31T04:19:52.695Z",
        "user": {
          "email_address": "[email protected]",
          "created_at": "2023-01-31T04:19:52.695Z"
        }
      }
    ]
  }
}

visit https://graphql.org for more documentations & Click this to connect me in insragram. thank you:D

typescript-graphql's People

Contributors

mframadann avatar

Stargazers

Roman avatar Syaeful Annas avatar Muhamad Muzani avatar  avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.