Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Authenticate GraphQL Requests #775

Draft
wants to merge 2 commits into
base: the-future
Choose a base branch
from
Draft

Conversation

NuckChorris
Copy link
Member

  • Refactor token-grabbing code to be shared between Apollo and Ajax services
  • Override Apollo service to add Auth header using apollo-link-context (via ember-auto-import)
  • Fix GraphQL API endpoint URL


return get(this, 'data.authenticated.access_token');
}),

Copy link
Member Author

Choose a reason for hiding this comment

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

Am I doing something obviously wrong here @trmcnvn? The ajax service isn't picking up on the authentication so I must be doing something wrong with computed properties :/

Copy link
Contributor

Choose a reason for hiding this comment

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

Nothing jumps out at me.

Have you tried using Ember.get around the conditional check? Maybe an issue there with ES6 getters.

Copy link
Member Author

Choose a reason for hiding this comment

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

I was thinking that but — everything works fine in a browser?

Is it possible that the test is checking before the runloop hits and updates the computed properties?

Copy link
Contributor

Choose a reason for hiding this comment

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

Oh, I thought it was broken in browser unrelated to tests, my bad.

The test will be failing because the session service is mocked and token doesn't exist in the mock.

Copy link
Member Author

Choose a reason for hiding this comment

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

Aha! Didn't realize it was being mocked for the tests. Thanks!

Copy link
Contributor

Choose a reason for hiding this comment

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

Okay, so the issue is with ember-auto-import being added.

Specifically, it's a conflict with moment/moment-timezone as we have them included via an addon that uses shims -- and we set the timezone on authentication.

Adding the following code to ember-cli-build.js should fix the remaining tests:

autoImport: {
  exclude: ['moment', 'moment-timezone']
}

However, there may be other issues as well. We'll need to list all shims as an excluded import most likely.

Copy link
Member Author

Choose a reason for hiding this comment

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

Well that's fun. At least the pain should be temporary. ember-auto-import is becoming default in ember-cli so shims should be going away in future

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants