Skip to content

krzywdal/GraphqlApiDemo

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

GraphqlApiDemo

GraphQL API Demo working with mongodb

GraphQL properties

spring.graphql.graphiql.enabled=true
spring.graphql.graphiql.path=/graphiql

GraphQL playground

http://localhost:8080/graphiql?path=/graphql

MongoDB properties

spring.data.mongodb.uri=mongodb://localhost:27017/bookdb
spring.data.mongodb.auto-index-creation=true

To get book by id

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

To get author by id

    {
      authorById(id: "author-1") {
        id,
        firstName,
        lastName
      }
    }

To add author

    mutation INSERT_NEW_AUTHOR {
        insertAuthor(createAuthorInput: {
            id: "author-1",
            firstName: "John",
            lastName: "Smith"})
        {
            id
            firstName
            lastName
        }
    }

About

GraphQL API Demo working with mongodb

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages