Could not find module `apollo-link-context`
See original GitHub issueThis issue seems to be similar to #137 but that was closed, seemingly without any fix or update. I was having lots of trouble getting ember-apollo-client to work in my actual application. Our Ember version is a bit out of date, so I created a new project just to get this running, so i can rule out version conflicts.
I’m trying to add some headers to my requests, but it doesn’t seem to know how to load apollo-link-context
. I see it in my node_modules, but am not sure what the problem is.
import { computed } from "@ember/object";
import ApolloService from "ember-apollo-client/services/apollo";
import { setContext } from "apollo-link-context";
export default ApolloService.extend({
link: computed(function() {
let httpLink = this._super(...arguments);
let authLink = setContext((request, context) => {
return this._runAuthorize(request, context);
});
return authLink.concat(httpLink);
}),
_runAuthorize() {
let headers = {};
headers['x-user-id'] = '100';
headers['x-user-uuid'] = 'jahhalhahoyhhalh';
return headers;
}
});
the error i’m seeing looks like:
Issue Analytics
- State:
- Created 4 years ago
- Reactions:1
- Comments:14 (4 by maintainers)
Top Results From Across the Web
Module not found: Can't resolve 'apollo-link-context'
I cant. Please run npm i apollo-link-context . You need to install apollo-link-context not just apollo-link ...
Read more >apollo-link-context
An easy way to set and cache context changes for Apollo Link. Latest version: 1.0.20, last published: 3 years ago.
Read more >Module not found: Can't resolve '@apollo/link-context' #5827
Intended outcome: As per the documentation Context Link I expected the package to exist. What is the issue here?
Read more >Migrating to Apollo Client 3.0
This article walks you through migrating your application to Apollo Client 3.0 from previous versions of Apollo Client. To illustrate the migration process, ......
Read more >Using with Apollo Client — absinthe v1.7.0
Using Apollo with an HTTP link does not require any Absinthe-specific ... You may find that you need to modify the HTTP request...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Hello @marsh73 and @sumeetattree!
If you are loading
apollo-link-context
from your app, you must add it as a direct dependency.For example:
You are overwriting the apollo service in your app (or engine). If in that file you are importing
apollo-link-context
or any other dependency, you need to add them to yourdevDependencies
as wellember-auto-import
. If you are in an engine, I believe you need to add it todependencies
.Let me know if that solved your problem.
I don’t think you need to inject the apollo service when using the mixin.