An example consuming a GraphQL API from JavaScript using graphql.js.
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.gitignore
LICENSE
README.md
client.js
fetch.js
index.html
package-lock.json
package.json

README.md

JavaScript GraphQL Example

Example consuming a GraphQL API from JavaScript using graphql.js.

See it live

https://codewithhugo.com/js-graphql-client-example/

Run Node script

$ npm install
$ node fetch.js
{
  "pokemon": {
    "attacks": {
      "special": [
        {
          "name": "Discharge"
        },
        {
          "name": "Thunder"
        },
        {
          "name": "Thunderbolt"
        }
      ]
    }
  }
}

Run client-side app

Locally

  • Clone the repo

  • Install dependencies

    $ npm install
  • Run using parcel:

    $ npm start # or npx parcel index.html
  • Open http://localhost:1234