Home

Awesome

ember-graphql-examples

Contributing

Any contributions are grealty appreciated, feel free to open a pull request! 🎉

Clients

This app provides of the examples of:

The application also includes a built-in GraphQL query client available at http://localhost:4200/api/graph.

Behind the scenes it is using ember-cli http-mocks with the json-graphql-server express middleware to provide a sample GraphQL api. The API is generated automatically from json data.

The http mock server is made available during tests by ember-cli-testem-http-mocks.

Querying

client.graphql filestringgenerated by ember-data-adapter
ember-apollo-client✅
ember-graphql-adapter✅
graphql-request✅
lokka✅

Relationships

"Relationships" in GraphQL are represented as a field with a list type.

clientrelationships
ember-apollo-client✅
ember-graphql-adapter✅ *
graphql-request✅
lokka✅

* ember-graphql-adapter

The way the ember-graphql-adapter generates its query for relationships, based on the model definition, is not compatible with the github api's use of relay-style pagination. Relay pagination wraps results in the nodes field, allows arguments for pagination, and more. There is likely manual work needed to map conventions between what the adapter expects and the queries it generates.

The ember-graphql-adapter is more closely coupled with the example in its documentation using the graphql gem. If your relationships aren't coupled in a strong relational way where your graphql types are entities, you might run into some problems.

Integration with ember-simple-auth

Login with a github access token at /login, if it is a valid token then it is set on the session and ember-simple-auth session is set to be "authenticated".

clientember-simple-auth integration
ember-apollo-client✅ †
ember-graphql-adapter✅
graphql-request✅ *
lokka✅ *

† ember-apollo-client authentication links

The ember apollo client supports the apollo links, a way of chaining modifications together. In this case we use the http-link to set the necessary Authorization header.

* Re-generating client instances (lokka, graphql-request)

There are outstanding issues for lokka (issue) and graphql-request (issue) that prevent dynamically changing/setting the authorization header. A wrapper service is setup in the same way for both lokka and graphql-request in which the client computed property depends on the session.data.token. Lingering client references that were saved in scope could fail to be used if they were setup with an old access token.

Linting queries against a schema with eslint-plugin-graphql

Testing

This example ember application also shows testing methods with polly.js, graphl-tools mock resolvers with pretender.js, and ember-cli-mirage-graphql.

General Tooling

There is some standardization in the GraphQL community to use .graphqlconfig files. This makes it easier to use with graphql-cli to generate a schema that is discoverable by the other tools.

Prerequisites

You will need the following things properly installed on your computer.

Installation

Running / Development

Code Generators

Make use of the many generators for code, try ember help generate for more details

Running Tests

Linting

Building

Deploying

Specify what it takes to deploy your app.

Further Reading / Useful Links