Skip to content

This repository showcases the creation of a GraphQL server using Fastify, Mercurius, and GraphQL. The project evolves through different versions, each offering more features and complex responses.

Notifications You must be signed in to change notification settings

tomsouza4/graphql-from-scratch

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Introduction

This repository showcases the creation of a GraphQL server using Fastify, Mercurius, and GraphQL. The project evolves through different versions, each offering more features and complex responses.

The project consists of three versions of a GraphQL server:

  • server_v0.js: Returns a hardcoded name and message.
  • server_v1.js: Expands functionality to request name and message.
  • server.js: Returns properties with attributes such as description and address.

Requirements

Ensure you have the following libraries installed:

Clone and Setup

Clone the repository:

This is how to get the project from Github

git clone https://github.com/tomsouza4/graphql-from-scratch.git

Or you can create your own: Navigate to the desired folder:

cd ~/Documents

Create and enter the folder:

mkdir graphql-from-scratch
cd graphql-from-scratch

Initialize the project:

npm init --yes

Install required libs for this project

npm install fastify mercurius graphql

Open the project with Visual Code(May require to add this PATH, on Visual Code run: Shell Command: Install 'code' command in PATH)

code .

Output Sample

server_v0.js

data	
     sayHello	
         name	"Akshay"
         message	"Akshay> Learning GraphQL"

server_v1.js

{
    "data": {
      "sayHello": {
        "name": "Luis F.",
        "message": "Luis F.> I like GraphQL"
      }
    }
  }

server.js

    1. Sample result from code:
{
    "data": {
      "availableProperties": [
        {
          "description": "A big house",
          "address": {
            "street": "123 Elm St",
            "city": "Miami",
            "state": "FL",
            "zipCode": 33137
          }
        }
      ]
    }
  }
    1. After updating const resolvers to filter by city
{
    "data": {
      "availableProperties": [
        {
          "description": "A big pink house with yellow people",
          "address": {
            "street": "321 Evergreen Lane",
            "city": "Springfield",
            "state": "MO",
            "zipCode": 44212
          }
        }
      ]
    }
  }

Resources Used

About

This repository showcases the creation of a GraphQL server using Fastify, Mercurius, and GraphQL. The project evolves through different versions, each offering more features and complex responses.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages