# Is Apollo Server v5 incompatible with RESTDataSource?

**URL:** <https://community.apollographql.com/t/is-apollo-server-v5-incompatible-with-restdatasource/9939>\
**Category:** Server\
**Created:** [July 6, 2026, 9:53pm UTC](https://community.apollographql.com/t/is-apollo-server-v5-incompatible-with-restdatasource/9939 "2026-07-06T21:53:20Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![ASJ98](https://sea1.discourse-cdn.com/flex019/user_avatar/community.apollographql.com/asj98/32/6509_2.png) [@ASJ98](https://community.apollographql.com/u/ASJ98)\
**Post date:** [July 6, 2026, 9:53pm UTC](https://community.apollographql.com/t/is-apollo-server-v5-incompatible-with-restdatasource/9939/1 "2026-07-06T21:53:20Z")

</div>

The @apolloapolloapolloapollo/server v5 documentation says to use RESTDataSource@apolloapollofrom @apollo/datasource-rest for interacting with REST APIs to provide caching.

This is not working for me locally and it seems to@apoapollobe because @apo@ap@apollollolo/server v5 has @apollo/utils.keyvaluecache v4@ap@apollolloas a dependency whilst @apollo/da@ap@apollolloasource-rest v6 (latest) has @apollo/utils.keyvaluecache v3 as a dependency.

Has anyone managed to get this to work with @apollo/server v5?

This is my API that extends RESTDataSource:

```auto
export class ContextAPI extends RESTDataSource {
  override baseURL: string = process.env.CONTEXT_API_URL!;
  loggingInfo: Logging;

  private static readonly label: string = "context-api";

  constructor(loggingInfo: Logging) {
    super();
    this.loggingInfo = loggingInfo;
  }

  protected override willSendRequest(
    _path: string,
    requestOpts: AugmentedRequest<CacheOptions>,
  ): ValueOrPromise<void> {
    requestOpts.headers["tracking-id"] = loggingInfo["tracking-id"];
  }

  async getContext(context: string) {
    return ResultAsync.fromPromise<IContextResponse, GraphQLError>(
      this.get("context", {
        params: {
          context,
        },
      }),
      (e) => {
        return new GraphQLError("Failed to get context", {
          extensions: {
            code: "CONTEXT_ERROR",
          },
          originalError: toError(e),
        });
      },
    );
  }
}

```

And this is the error I get when I call my Context query in an integration test with `executeOperation`

```auto
"stacktrace": [
        "TypeError: Cannot read private member #keyMap from an object whose class did not declare it",     
        " at LRUCache.get (C:\\Users\\123\\dev\\my-project\\node_modules\\lru-cache\\dist\\commonjs\\index.js:1366:28)",
        " at InMemoryLRUCache.get (C:\\Users\\123\\dev\\my-project\\node_modules\\@apollo\\utils.keyvaluecache\\dist\\InMemoryLRUCache.js:29:27)",
        " at PrefixingKeyValueCache.get (C:\\Users\\123\\dev\\my-project\\node_modules\\@apollo\\utils.keyvaluecache\\dist\\PrefixingKeyValueCache.js:18:29)",
        " at HTTPCache.fetch (C:\\Users\\123\\dev\\my-project\\node_modules\\@apollo\\datasource-rest\\dist\\HTTPCache.js:60:40)",
        " at C:\\Users\\123\\dev\\my-project\\node_modules\\@apollo\\datasource-rest\\dist\\RESTDataSource.js:190:101",
        " at ContextAPI.trace (C:\\Users\\123\\dev\\my-project\\node_modules\\@apollo\\datasource-rest\\dist\\RESTDataSource.js:274:20)",
        " at performRequest (C:\\Users\\123\\dev\\my-project\\node_modules\\@apollo\\datasource-rest\\dist\\RESTDataSource.js:183:25)",
        " at ContextAPI.fetch (C:\\Users\\123\\dev\\my-project\\node_modules\\@apollo\\datasource-rest\\dist\\RESTDataSource.js:229:40)",
        " at processTicksAndRejections (node:internal/process/task_queues:105:5)",
        " at ContextAPI.get (C:\\Users\\123\\dev\\my-project\\node_modules\\@apollo\\datasource-rest\\dist\\RESTDataSource.js:111:17)",
      ]

```

---

<div class="post-metadata">

**Author:** ![lenz](https://sea1.discourse-cdn.com/flex019/user_avatar/community.apollographql.com/lenz/32/4007_2.png) [@lenz](https://community.apollographql.com/u/lenz)\
**Post date:** [July 7, 2026, 7:45am UTC](https://community.apollographql.com/t/is-apollo-server-v5-incompatible-with-restdatasource/9939/2 "2026-07-07T07:45:28Z")

</div>

Usually, in that case your package manager would just install v4 into `node_modules/@apollo/server/node_modules/@apollo/utils.keyvaluecache` and v3 into `node_modules/@apollo/datasource-rest/node_modules/@apollo/utils.keyvaluecache` and there should not be any problems.

---

<div class="post-metadata">

**Author:** ![ASJ98](https://sea1.discourse-cdn.com/flex019/user_avatar/community.apollographql.com/asj98/32/6509_2.png) [@ASJ98](https://community.apollographql.com/u/ASJ98)\
**Post date:** [July 7, 2026, 8:12am UTC](https://community.apollographql.com/t/is-apollo-server-v5-incompatible-with-restdatasource/9939/3 "2026-07-07T08:12:27Z")

</div>

Thank you for getting back to me. I am using npm, and have added the stack trace of the error I got. Is there any more info I can provide that could help?

v4.0.0 did get installed in package-lock at `node_modules/@apollo/server/node_modules/@apollo/utils.keyvaluecache`

But there is no value for `"node_modules/@apollo/datasource-rest/node_modules/@apollo/utils.keyvaluecache"` ,however, v3.1.0 in installed under `"node_modules/@apollo/utils.keyvaluecache"` and also under `"node_modules/@apollo/utils.keyvaluecache"`
