Skip to content
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

Server 2.0: Error: Cannot read property 'setCacheHint' of undefined #1201

Closed
ovaris opened this issue Jun 20, 2018 · 7 comments
Closed

Server 2.0: Error: Cannot read property 'setCacheHint' of undefined #1201

ovaris opened this issue Jun 20, 2018 · 7 comments

Comments

@ovaris
Copy link

ovaris commented Jun 20, 2018

Hi,

trying to set cache programatically in my resolver, using latest apollo-server-express rc.0, the info parameter doesn't contain cacheControl:
Error: Cannot read property 'setCacheHint' of undefined

https://www.apollographql.com/docs/engine/caching.html#resolver-hints

items: (parent: any, args: any, context: any, { cacheControl }: any) => {
        cacheControl.setCacheHint({ maxAge: 60000 });
    },
@evans
Copy link
Contributor

evans commented Jun 20, 2018

Ah yes! Thank you for opening the issue. Under the hood we are using mergeSchema to support file uploads. Currently it breaks cache-control, so we'll be removing it with #1204 and releasing another rc later today or tomorrow.

@evans
Copy link
Contributor

evans commented Jun 21, 2018

We've released RC.1, which solves the issue of cacheControl being undefined. Definitely caused by mergeSchemas. I've tested locally, so I feel comfortable closing. Thank you @ovaris for opening the original issue!

@evans evans closed this as completed Jun 21, 2018
@eberhara
Copy link
Contributor

eberhara commented Sep 19, 2018

@evans how are you doing?
Is this fix on [email protected]?

I am using this version + mergeSchemas to merge remote and local schemas. The problem is that cacheControl is still undefined for me.

When I remove the mergeSchemas, it works fine for me. Can i keep using it?

@schettino
Copy link

I was also facing this. Turns out that it's the transformSchema that is currently breaking the cache-control.

@aviralnx
Copy link

Hi,
is this still not fixed?
getting the same error as @ovaris

@glasser
Copy link
Member

glasser commented May 18, 2021

@Aviral-swa Is it possible that this is the same as the issue described at #4810 (comment) ?

@ashakhray2
Copy link

I had the same issue. The mergeSchemas doesn't work correctly.
The fix is use the mergeSchemas from @graphql-tools/schema (tested on 8.3.11)
const { mergeSchemas } = require('@graphql-tools/schema')
Works.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 20, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants