GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - ns-code/spring-graphql: This project extends the official Spring GraphQL demo by adding a MutationMapping

BranchesTags
Open more actions menu

Latest commit

 

History

2 Commits
2 Commits

Folders and files

NameName
Last commit message
Last commit date
gradle/wrapper
gradle/wrapper
 
 
src
src
 
 
.gitattributes
.gitattributes
 
 
.gitignore
.gitignore
 
 
LICENSE
LICENSE
 
 
README.md
README.md
 
 
build.gradle
build.gradle
 
 
gradlew
gradlew
 
 
gradlew.bat
gradlew.bat
 
 
settings.gradle
settings.gradle
 
 

Repository files navigation

Spring Boot GraphQL

Description

This project has a helloworld style demo for Spring Boot support for GraphQL. This demo extends the official demo at https://spring.io/guides/gs/graphql-server by adding a mutation mapping.

Running

.\gradlew bootRun

Integration Testing

.\gradlew test

Alternatively, using curl:
QueryMapping:
curl -X POST "http://localhost:8080/graphql"   -H "Content-Type: application/json"   -d "{\"query\": \"query { bookById(id:\\\"book-1\\\") { id name pageCount author { id firstName lastName } } }\"}"

gives
{"data":{"bookById":{"id":"book-1","name":"Effective Java","pageCount":416,"author":{"id":"author-1","firstName":"Joshua","lastName":"Bloch"}}}}

MutationMapping:
curl -X POST "http://localhost:8080/graphql" -H "Content-Type: application/json"  -d "{  \"query\": \"mutation AddBook($input: BookInput!) { addBook(book: $input) { id name pageCount author { id firstName lastName } } }\",    \"variables\": {      \"input\": {        \"id\": \"book-44\",        \"name\": \"The Hitchhiker's Guide to GraphQL\",        \"pageCount\": 420,        \"author\": {          \"id\": \"authid44\",          \"firstName\": \"Douglas\",          \"lastName\": \"Adams\"        }      }    }}"

gives
{"data":{"addBook":{"id":"book-44","name":"The Hitchhiker's Guide to GraphQL","pageCount":420,"author":{"id":"authid44","firstName":"Douglas","lastName":"Adams"}}}}


E2E Testing QueryMapping

Access the UI http://localhost:8080/graphiql?path=/graphql

Running 
query bookDetails {
  bookById(id: "book-1") {
    id
    name
    pageCount
    author {
      id
      firstName
      lastName
    }
  }
}

should give
{
  "data": {
    "bookById": {
      "id": "book-1",
      "name": "Effective Java",
      "pageCount": 416,
      "author": {
        "id": "author-1",
        "firstName": "Joshua",
        "lastName": "Bloch"
      }
    }
  }
}

E2E Testing MutationMapping

Running
mutation AddBook {
  addBook(
    book: {
      id: "book-4"
      name: "The Hitchhiker's Guide to GraphQL"
      pageCount: 420
      author: {
        id: "author-5"
        firstName: "Douglas"
        lastName: "Adams"
      }
    }
  ) {
    id
    name
    pageCount
    author {
      id
      firstName
      lastName
    }
  }
}

should give
{
  "data": {
    "addBook": {
      "id": "book-4",
      "name": "The Hitchhiker's Guide to GraphQL",
      "pageCount": 420,
      "author": {
        "id": "author-5",
        "firstName": "Douglas",
        "lastName": "Adams"
      }
    }
  }
}

About

This project extends the official Spring GraphQL demo by adding a MutationMapping

Resources

Readme
MIT license
Activity

Stars

0 stars

Watchers

0 watching

Forks

0 forks
Report repository

Releases

Packages

Contributors

Languages

You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.