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

Extend type with cacheControl doesn't work #903

Closed
eduardojmatos opened this issue Jul 25, 2018 · 5 comments
Closed

Extend type with cacheControl doesn't work #903

eduardojmatos opened this issue Jul 25, 2018 · 5 comments
Labels
good first issue help wanted Extra attention is needed

Comments

@eduardojmatos
Copy link

eduardojmatos commented Jul 25, 2018

Hi people! It's my first issue here, and I have a specific problem encountered on my project using stitching and cache with apollo engine.

We're extending types to add some fields. This is the scenario:

graph/schemas/extend/category.js

export default `
  extend type Category @cacheControl(maxAge: 1000, scope: PUBLIC) {
    services(first: Int): ServiceConnection @cacheControl(maxAge: 2000, scope: PUBLIC)
  }
`;

The field services is a stitching of another server that has a ServiceConnection type. We make the realtionship with Category is a categorySlug field. But this is not the problem!

The result, on the "extensions" property return this:

{
  "cacheControl": {
    "version": 1,
    "hints": [
      {
        "path": [
          "category"
        ],
        "maxAge": 0
      },
      {
        "path": [
          "category",
          "services"
        ],
        "maxAge": 2000,
        "scope": "PUBLIC"
      }
    ]
  }
}

The maxAge of path category it's not set as 1000. I don't know if this is the expected behavior.

@ghost ghost added good first issue help wanted Extra attention is needed labels Jul 25, 2018
@januszhou
Copy link

Having the same issue here, any suggestions?

@hastarin
Copy link

I'd also tried this. It would be great to proxy a remote schema, such as AppSync which doesn't allow custom directives, and stitch in cacheControl directives to then serve it up via Apollo Server.

Sadly I ran into a number of issues.

The first being with graphql@14.0.x there is an SDL validation failure when trying to merge for the custom directive which I was unable to get around.

After downgrading I then hit the same issue reported here.

@yaacovCR
Copy link
Collaborator

This seems to be a bug within the cacheControl extension support by Apollo. A workaround would be to create a way to enhance using directives as metadata, possibly, for example, automatically copying the directives from the extensionAstNodes to the primary astNode.

@yaacovCR
Copy link
Collaborator

Related, but different, what if you can't even use extend, like with existing fields, as in #451.

@yaacovCR
Copy link
Collaborator

yaacovCR commented Oct 6, 2020

You would use mergeSchemas which should hopefully merge directives...

Closing for now as there is no bug in tools...

@yaacovCR yaacovCR closed this as completed Oct 6, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

4 participants