DEV Community

Jean Machuca for QCObjects

Posted on

2 1

Making a GraphQL Micro-service with QCObjects HTTP2 Built-In Server

In the following step-by-step tutorial I'll show you how to make a fancy, clean and quick micro-service using QCObjects HTTP2 Built-In Server and GraphQL

If you want to know more about GraphQL go to https://graphql.org

If you want to learn more about QCObjects go to https://qcobjects.dev

1.- Create a progressive web app using the command line of QCObjects CLI Tool (you should be inside the project's folder):

> qcobjects create --pwa mynewmicroservice

2.- Install GraphQL inside the project's folder:

> npm install graphql --save

3.- Create/Edit a config.json file inside the project's folder

> vi config.json

4.- In the new config.json file add the following lines:

{
  "relativeImportPath": "js/packages/",
  "domain": "0.0.0.0",
  "backend": {
    "routes": [{
      "path": "/helloworld",
      "microservice": "org.quickcorp.custom.backend.helloworld"
    }]
  }
}

5.- Then create/edit a new package inside the js/packages folder:

> vi js/packages/org.quickcorp.custom.backend.helloworld.js

6.- The following animation shows the basic code of a Microservice using GraphQL and QCObjects HTTP2 Built-In Server

QCOBJECTS GRAPHQL Microservice Code.gif

7.- Launch the QCObjects HTTP2 Built-In Server using the following command line:

> qcobjects launch mynewmicroservice

8.- Then open a browser in the address https://127.0.0.1/helloworld and you should see a result like this:

QCObjects GraphQL Microservice Result.png

Hostinger image

Get n8n VPS hosting 3x cheaper than a cloud solution

Get fast, easy, secure n8n VPS hosting from $4.99/mo at Hostinger. Automate any workflow using a pre-installed n8n application and no-code customization.

Start now

Top comments (0)

SurveyJS custom survey software

JavaScript Form Builder UI Component

Generate dynamic JSON-driven forms directly in your JavaScript app (Angular, React, Vue.js, jQuery) with a fully customizable drag-and-drop form builder. Easily integrate with any backend system and retain full ownership over your data, with no user or form submission limits.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay