Git Product home page Git Product logo

graphql-java's Introduction

GraphQL Java Example.

graphql.version: 3.0.0, new versions required code changes.

Requirements.

  • a mongoDB with name hackernews.
  • there are graphql command to send inserts below.

MAVEN COMMAND

mvn jetty:run

Maven Debugging options

SET MAVEN_OPTS="-Xdebug -Xnoagent -Djava.compiler=NONE -Xrunjdwp:transport=dt_socket,address=8000,server=y,suspend=n"

LOCAL URL

http://localhost:8080/

check the console for, it need to be updated on index.html with the new bearer.

'Authorization': 'Bearer 5dadac6d02c13df6537abe5b',

mongoDB create user manually.

{
    name: "user1",
    email: "[email protected]" ,
    password: "secret"
}

mutation createUser (this was an intermediate step, that after authentication is being added does not works)

mutation createUser {
  createUser(
    name: "user1"
    authProvider: {
      email: "[email protected]"
      password: "secret"
    }
  )
}

mutation signIn

mutation signIn {
  signinUser(
    auth: {
      email: "[email protected]",
      password: "secret"
    }) {
    token
    user {
      id
      name
    }
  }
}

mutation signIn {
  signinUser(
    auth: {
      email: "[email protected]",
      password: "secret2"
    }) {
    token
    user {
      id
      name
    }
  }
}

mutation createLink

mutation createLink {
  createLink(url: "www.google.com", description: "search engine") {
    url
    description
  }
}

mutation createLink {
  createLink(url: "spring.io", description: "spring framework home") {
    url
    description
  }
}

mutation createLink {
  createLink(url: "mvnrepository.com", description: "maven repository central") {
    description
    postedBy {
      id
      name
    }
  }
}

Queries examples

--- querying without fields, will return only ids.
{
  allLinks
}
is equivalent to
{
  allLinks {
    id
  }
}

--- querying for some extra fields
{
  allLinks {
    id
    url
    description
    postedBy {
      id
    }
  }
}

--- querying for all available fields
{
  allLinks {
    id
    url
    description
    postedBy {
      id
      name
      email
      password
    }
  }
}

Queries with filters.

--- filter by description_contains
{
  allLinks (filter: { description_contains: "engine" } ) {
    id
    url
    description
    postedBy {
      id
      name
      email
      password
    }
  }
}

--- filter by url_contains
{
  allLinks (filter: { url_contains: "tube" } ) {
    id
    url
    description
    postedBy {
      id
      name
      email
      password
    }
  }
}

--- filter by both
{
  allLinks (filter: { description_contains: "e", url_contains: "o" } ) {
    id
    url
    description
    postedBy {
      id
      name
      email
      password
    }
  }
}

-- filter + pagination
{
  allLinks (filter: { description_contains: "e", url_contains: "o" } first: 2) {
    id
    url
    description
    postedBy {
      id
      name
      email
      password
    }
  }
}

-- filter + pagination
{
  allLinks (filter: { description_contains: "e", url_contains: "o" } skip: 3) {
    id
    url
    description
    postedBy {
      id
      name
      email
      password
    }
  }
}

mutation createVote

mutation createVote {
  createVote(linkId: "5dadbf4c5cc91c5ca4602731", userId: "5dadac6d02c13df6537abe5b") {
    createdAt
    user
  }
}

mutation createVote {
  createVote(linkId: "5dadbf4c5cc91c5ca4602731", userId: "5dadac6d02c13df6537abe5b") {
    createdAt
    user {
      id
      name
    }
  }
}

graphql-java's People

Contributors

ezequiel-g avatar nikolasburk 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.