Giter Club home page Giter Club logo

graphql-with-spring-boot's Introduction

GraphQL & Springboot Learning

Following along an Udemy course

Build using mvn clean install and then run the GraphQLWithSpringBootApplication class

Launch webapp using http://localhost:8080/graphiql. Alternatively you can use altair browser plug and use URL http://localhost:8080/graphql.

It also uses H2 in-memory database, and it inserts data from data.sql file. For admin console of database connect to it using http://localhost:8080/h2-console. User/psw is sa/password.

The database structure

   Student(id, firstName, lastName..)
     --> Address(id, street..) - one-to-one relationship with student
     --> Subject(subjectName, marksObtained..) - one-to-many  relationship with student.  It holds marks scored by the student for a given subject.

Queries that are supported

Simple Query

This query doesn't have a parameter and returns a String

query{
   firstQuery
}

Query with parameter

Accepts a Type called sampleRequest with 2 fields firstName and lastName. It then concatenates and returns full name.

Note that firstName is a required field. Try the query without firstName to see the validation error.

query{
  fullName(sampleRequest: {
    firstName: "Satish"
    lastName: "Babu"
  })
}

Query that pulls data from JPA

query{
    Student(id: 101){
        id
        firstName
        lastName
        email
        street
        city
        learningSubjects {
            id
            subjectName
            marksObtained
        }
    }
}

Query with filter condition

The filter can be on the edge between student and subject (subselect of student)

query{
  Student(id: 101){
    id
    firstName
    lastName
    email
    street
    city
    fullName
    learningSubjects(subjectNameFilter: Java) {
      id
      subjectName
      marksObtained
    } 
  }
}

graphql-with-spring-boot's People

Contributors

satishbabu avatar

Stargazers

 avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.