Urigo/graphql-modules

info object is missing cacheControl in v2

martyganz opened this issue · 2 comments

Hi guys,

long time no see :)

Describe the bug

info is missing the cacheControl when using apollo server (ApolloServerPluginCacheControl) with graphql-modules v2.

To Reproduce
Minimal reproduction is here:
https://github.com/martyganz/apollo-cache-control-graphql-modules

  1. Run yarn
  2. Run yarn nodemon src/index.ts
  3. Fire the only query: curl 'http://localhost:4000/' -H 'Accept-Encoding: gzip, deflate, br' -H 'Content-Type: application/json' -H 'Accept: application/json' -H 'Connection: keep-alive' -H 'DNT: 1' -H 'Origin: http://localhost:4000' --data-binary '{"query":"# Write your query or mutation here\nquery getFlight {\n flight\n}"}' --compressed
  4. See undefined in console (info.cacheControl is logged from the resolver)

Expected behavior

cacheControl is not undefined so I can set cache headers from my resolvers.

Environment:

  • OS: MacOS
  • @graphql-modules/2.0.0:
  • NodeJS: LTS 14 (fermium)

Additional context

Came across this when finally upgrading our projects to graphql-modules v2 and latest apollo-server ;)

I tried patching things by passing typeDefs and resolvers directly to apollo server but that also did not fix it.

cc @donroyco

MIght be related to #1529.

It is not possible to have Apollo specific extensions in GraphQLResolveInfo when you use the wrapped schema generated by createSchemaForApollo because it has an additional execution layer besides Apollo's
So I recommend you to switch to createApolloExecutor.
You can check the example in this PR;
https://github.com/Urigo/graphql-modules/pull/2204/files

That worked, thanks!