question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Could not find module `apollo-link-context`

See original GitHub issue

This 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:

Screen Shot 2019-04-02 at 6 34 33 AM

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:1
  • Comments:14 (4 by maintainers)

github_iconTop GitHub Comments

3reactions
josemarluedkecommented, Apr 3, 2019

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 your devDependencies as well ember-auto-import. If you are in an engine, I believe you need to add it to dependencies.

Let me know if that solved your problem.

2reactions
josemarluedkecommented, Apr 4, 2019

I don’t think you need to inject the apollo service when using the mixin.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found