Any contributions are grealty appreciated, feel free to open a pull request! π
This app provides of the examples of:
- Setting up GraphQL Clients
- Different ember acceptance test techniques for GraphQL
- Linting queries against a schema
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.
| client | .graphql file | string | generated by ember-data-adapter |
|---|---|---|---|
ember-apollo-client |
β | ||
ember-graphql-adapter |
β | ||
graphql-request |
β | ||
lokka |
β |
"Relationships" in GraphQL are represented as a field with a list type.
| client | relationships |
|---|---|
ember-apollo-client |
β |
ember-graphql-adapter |
β * |
graphql-request |
β |
lokka |
β |
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.
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".
| client | ember-simple-auth integration |
|---|---|
ember-apollo-client |
β β |
ember-graphql-adapter |
β |
graphql-request |
β * |
lokka |
β * |
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.
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.
.eslintrc.js- Setup theeslint-plugin-graphqlconfiguration withember-cli-build.js- include an entry if you need a.graphqlfiles linted.graphqlconfignot required but if setup can be used byeslint-plugin-graphqlfor finding the schema
This example ember application also shows testing methods with polly.js, graphl-tools mock resolvers with pretender.js, and ember-cli-mirage-graphql.
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.
You will need the following things properly installed on your computer.
- Git
- Node.js (with npm)
- Ember CLI
- Google Chrome
git clone <repository-url>this repositorycd ember-graphql-examplesnpm install
ember serve- Visit your app at http://localhost:4200.
- Visit your tests at http://localhost:4200/tests.
Make use of the many generators for code, try ember help generate for more details
ember testember test --server
npm run lint:jsnpm run lint:js -- --fix
ember build(development)ember build --environment production(production)
Specify what it takes to deploy your app.