Skip to content

Galz648/graphql-over-rest

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

GraphQL over REST Example

This project demonstrates how to implement a GraphQL API layer over an existing REST API using Apollo Server. It uses the JSONPlaceholder API as an example REST endpoint.

Features

  • GraphQL server using Apollo Server
  • REST API integration using Axios
  • Example queries for Users and Posts
  • Nested resolvers for related data

Getting Started

  1. Install dependencies:
pnpm install
  1. Start the development server:
pnpm dev

The GraphQL server will be available at http://localhost:4000

Example Queries

Get all posts with their authors

query {
  posts {
    id
    title
    body
    user {
      id
      name
      email
    }
  }
}

Get a specific user with their posts

query {
  user(id: "1") {
    name
    email
    posts {
      id
      title
      body
    }
  }
}

Project Structure

  • src/index.js - Main server file containing GraphQL schema and resolvers
  • REST API integration is handled in the resolvers
  • Uses JSONPlaceholder API (https://jsonplaceholder.typicode.com) for demo data

Technologies Used

  • Node.js
  • Apollo Server
  • GraphQL
  • Axios for HTTP requests
  • PNPM for package management

graphql-over-rest

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published