/js-graphql-client-example

An example consuming a GraphQL API from JavaScript using graphql.js.

Primary LanguageHTMLMIT LicenseMIT

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