GraphQL client for apps using Parse Server
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
src
test
.babelrc
.codeclimate.yml
.editorconfig
.eslintrc
.gitignore
.npmignore
.travis.yml
CHANGELOG.md
LICENSE
README.md
gulpfile.babel.js
package.json

README.md

GraphQL client for apps using Parse Server

Build Status Code Climate Test Coverage Dependency Status devDependency Status

When to use

  • you are using Parse SDK (web or mobile) coupled with Parse Server
  • you are using GraphQL
  • you want to make sure your GraphQL queries are authenticated using Parse authentication
  • [Recommended] you are also uing parse-graphql-server package

Quick start

Install parse-graphql-client and make sure Parse JavaScript SDK is installed and configured

npm install --save parse-graphql-client parse

Create and configure and instance of GraphQLClient.

Note: GraphQLClient expects you to specify which Parse module to use. Example below uses a React Native version of Parse. If you are using GraphQLClient in a node environment, you would use require('parse/node'), while a browser based app would call for require('parse')

import GraphQLClient from 'parse-graphql-client';

const client = new GraphQLClient(settings.graphqlURL, require('parse/react-native'));

client.query(`
  {
    todos {
      id, text, isComplete
    }
  }
`).then(result => {
  console.log(result.todos);
});

return client.mutate(`
  {
    newTodo: addTodo(text:"buy milk") {
      id, text, isComplete
    }
  }
`).then(result => {
  console.log(result.newTodo);
});

All resulting requests to your GraphQL server will arrive with Authorization header set to current Parse session token. You can either take it from there, or use parse-graphql-server package to automate this even further.

See it in action

Credits

Parse GraphQL client relies heavily on Lokka from Kadirahq.