Skip to content

JuviDev/nestjs-graphql-federation

Repository files navigation

NestJS GraphQL Apollo

Installation

pnpm install

Running the app

# development
$ pnpm run start

# watch mode
$ pnpm run start:dev
$ pnpm run start:dev users
$ pnpm run start:dev posts

# production mode
$ pnpm run start:prod

Test

# unit tests
$ pnpm run test

# e2e tests
$ pnpm run test:e2e

# test coverage
$ pnpm run test:cov

GraphQL

Open the browser and go to http://localhost:3002/graphql

HTTP Headers for the requests

{
  "Authorization": "123"
}

Mutations

# Create User
mutation {
  createUser(
    createUserInput:{id: "123", email:"test@mail.com", password:"test" }){
    id
    email
    password
  }
}

# Create Post
mutation {
  createPost(createPostInput: { authorId: "123", id: "234" , body: "Text of the post"}){
    id
    authorId
    body
  }
}

Queries

# Get all Users
query {
  users {
    id
    email
    password
    posts{
      id
      authorId
      body
    }
  }
}

# Get all Posts
query {
  posts {
    id 
    authorId
    body
    user{
      id
      email
      password
    }
  }
}

About

Federation with Nest.js, GraphQL, Apollo

Topics

Resources

Stars

Watchers

Forks

Contributors