-
Notifications
You must be signed in to change notification settings - Fork 153
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
base: the-future
Are you sure you want to change the base?
Conversation
NuckChorris
commented
Feb 16, 2019
- 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'); | ||
}), | ||
|
There was a problem hiding this comment.
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 :/
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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!
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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