Skip to content

maxzz/test-graphql

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Description

Testing the GraphQL server implementation.

Use

Run yarn dev and open localhost:4000

Queries and mutations

Ask highlights

Query all records

query {
  highlights {
    id
    content
    title
    author
  }
}

or just some fields

query {
  highlights {
    title
    author
  }
}

Result:

{
  "data": {
    "highlights": [
      {
        "title": "Dharma Bums",
        "author": "Jack Kerouac"
      },
      {
        "title": "Arbitrary Stupid Goal",
        "author": "Tamara Shopsin"
      }
    ]
  }
}
Query for an individual note by including an ID parameter with our query
query {
  highlight(id: "1") {
    content
  }
}

Result:

{
  "data": {
    "highlight": {
      "content": "One day I will find the right words, and they will be simple."
    }
  }
}
Mutation: Add Record
mutation {
  newHighlight(author: "Adam Scott" title: "JS Everywhere" content: "GraphQL is awesome") {
    id
    author
    title
    content
  }
}

Result:

{
  "data": {
    "newHighlight": {
      "id": "3",
      "author": "Adam Scott",
      "title": "JS Everywhere",
      "content": "GraphQL is awesome"
    }
  }
}
Mutation: Delete Record
mutation {
  deleteHighlight(id: "3") {
    id
  }
}

Result:

{
  "data": {
    "deleteHighlight": {
      "id": "3"
    }
  }
}

Sources

Get Started Building GraphQL APIs With Node

About

GraphQL server test implementation.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published