/graphql-api

Api with GraphQL, Mysql and Knex

Primary LanguageJavaScript

Graphql

Api feita com GraphQL

Configuration   |    Technologies   |    Queries   |    Mutations   |   

🔧 Configuration

  • cd graphql-api
  • npm install
  • crie seu arquivo .env
  • create database products-graphql
  • npx knex migrate:latest
  • npm start

🚀 Technologies

  • Apollo-server
  • Node
  • Nodemon
  • Knex
  • Mysql
  • Graphql
  • Dotenv

📖 Queries

Query 'products':

  products {
    id name quantity price
  }

Response:

  {
    data: {
      products: [
        {
          id: 1,
          name: "Example",
          quantity: 1,
          price: 1
        }
      ]
    }
  }

Query 'product(id: Int)':
  product(id: 1) {
    id name quantity price
  }

Response:

  {
    data: {
      product: {
        id: 1,
        name: "Example",
        quantity: 1,
        price: 1
      }
    }
  }

📓 Mutations

Mutation 'newProduct(data: ProductInput)':

  newProduct(data: ProductInput) {
      id name quantity price
  }

Response:

  {
    data: {
      newProduct: {
        id: 1,
        name: "Example",
        quantity: 1,
        price: 1
      }
    }
  }

Mutation 'updateProduct(id: Int, data: ProductInput)':
  updateProduct(id: Int, data: ProductInput) {
      id name quantity price
  }

Response:

  {
    data: {
      updateProduct: {
        id: 1,
        name: "New name",
        price: 1,
        quantity: 1
      }
    }
  }

Mutation 'deleteProduct(id: Int)':
  deleteProduct(id: Int) {
      id name quantity price
   }

Response:

  {
    data: {
      deleteProduct: {
        id: 1,
        name: "Example",
        quantity: 1,
        price: 1
      }
    }
  }

Que a força esteja com você 💪