Novices Performing Miracles

    generator-graphql-typescript

    2.0.0 • Public • Published

    generator-graphql-typescript NPM version Build Status Coverage percentage

    Create a Graphql API in typescript with type-graphql and Typeorm

    Installation

    First, install Yeoman and generator-rest-express-typescript using npm (we assume you have pre-installed node.js).

    npm install -g yo
    npm install -g generator-graphql-typescript

    Then generate your new project:

    yo graphql-typescript myapp

    Getting Started

    • Run npm start to preview and watch for changes
    • Run npm run build to create the production version
    • Run npm run test to lauch jest test

    Queries

    Login

    query login(
        input: $input
      ) {
        ... on LoginType {
          __typename
          token
        }
        ... on UserError {
          __typename
          message
        }
      }
    }

    Get projects

    You need to put the token you get from the login query to perform this query. Prefix the authorization header with bearer.

    {
      "Authorization": "bearer thetoken"
    }
    query {
      projects { 
        name,
        owner { email }
      }

    Mutations

    Register

    mutation {
      register(
        input: $input
      ) {
        ... on User {
          __typename
          username
          email
        }
        ... on UserError {
          __typename
          message
        }
      }
    }

    Add project

    You need to put the token you get from the login query to perform this query. Prefix the authorization header with bearer.

    {
      "Authorization": "bearer thetoken"
    }
    mutation {
      createProject(
        input: $input
      ) {
        __typename
        ... on Project {
          name
        }
        ... on UserError {
          message
        }
      }
    }

    TODO 🚧

    • Add subcommand to create a new resolver

    Contribute

    See the contributing docs.

    License

    MIT © Clément Lafont

    Install

    npm i generator-graphql-typescript

    DownloadsWeekly Downloads

    3

    Version

    2.0.0

    License

    MIT

    Unpacked Size

    37.5 kB

    Total Files

    41

    Last publish

    Collaborators

    • johnrazeur