Skip to content

Commit

Permalink
Adapted documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
theodorDiaconu committed Jul 26, 2018
1 parent 685b886 commit dcd767e
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 7 deletions.
22 changes: 15 additions & 7 deletions docs/accounts.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@ export default {
```js
import { initialize } from 'meteor/cultofcoders:apollo';

initialize({
USER_DEFAULT_FIELDS: {
initialize({}, {
// You can configure your default fields to fetch on GraphQL request
// This works with Subscription onConnect()
userDefaultFields: {
_id: 1,
username: 1,
emails: 1,
roles: 1,
}
}),
Expand Down Expand Up @@ -82,6 +82,8 @@ localStorage.setItem('Meteor.loginToken', token); // the one you received from t
Create a quick `me` query:

```js
import { load } from 'meteor/cultofcoders:apollo';

const typeDefs = `
type Query {
me: User
Expand All @@ -96,7 +98,10 @@ const resolvers = {
},
};

export { typeDefs, resolvers };
load({
typeDefs,
resolvers,
});
```

And try it out:
Expand All @@ -112,9 +117,12 @@ query {
And also register the proper clear-outs for live subscription authentication:

```js
// file: client/accounts.js
// file: client/main.js
import { initialize } from 'meteor/cultofcoders:apollo';
import { onTokenChange } from 'meteor-apollo-accounts';
import { wsLink, client } from 'meteor/cultofcoders:apollo';

// Preferably you instantiate it in a different place
const { client, wsLink } = initialize();

onTokenChange(function() {
client.resetStore();
Expand Down
3 changes: 3 additions & 0 deletions docs/settings.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@ initialize({}, {
// So basically the `gui` config from `ApolloConstructorOptions` will be ignored
gui: Meteor.isDevelopment

// Load custom schema directives that you want to use
schemaDirectives: []

// Because we support authentication by default
// We inject { user, userId } into the context
// These fields represent what fields to retrieve from the logged in user on every request
Expand Down

0 comments on commit dcd767e

Please sign in to comment.