Skip to content
This repository has been archived by the owner on Jan 15, 2020. It is now read-only.

Login with current user in GraphiQL #35

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@
All notable changes to this project will be documented in this file. [*File syntax*](http://keepachangelog.com/).
This project adheres to [Semantic Versioning](http://semver.org/).

## VNEXT
### New features

- Automatically pass Meteor authentication in GraphiQL ([@nicolaslopezj](https://github.com/nicolaslopezj) in [#35](https://github.com/apollostack/meteor-integration/pull/35)).

## [0.1.0] - 2016-08-05
### Updated

Expand Down
8 changes: 6 additions & 2 deletions main-server.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,13 @@ const defaultConfig = {
maxAccountsCacheSizeInMB: 1,
graphiql : Meteor.isDevelopment,
graphiqlPath : '/graphiql',
graphiqlOptions : {}
graphiqlOptions : {
passHeader : "'Authorization': localStorage['Meteor.loginToken']"
}
};

const defaultOptions = {
formatError: e => ({
formatError: e => ({
message: e.message,
locations: e.locations,
path: e.path
Expand All @@ -28,7 +30,9 @@ const defaultOptions = {

export const createApolloServer = (givenOptions, givenConfig) => {

let graphiqlOptions = Object.assign({}, defaultConfig.graphiqlOptions, givenConfig.graphiqlOptions);
let config = Object.assign({}, defaultConfig, givenConfig);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this line should take care of all attributes, including graphiqlOptions?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we do it that way any graphiqlOptions that we pass will override the whole defaultConfig.graphiqlOptions object. That's because Object.assign is not deep.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah, thanks

config.graphiqlOptions = graphiqlOptions;

const graphQLServer = express();

Expand Down