Cost directives from subgraphs not seem to be respected by Demand Control in Gateway #897
-
Hey, Firstly, thanks for a beautiful work you're doing here! I have pretty general question about Federation + Gateway + (I think Hive itself). I want to use Gateway with Demand Control to limit the query cost. For subgraphs I use HotChocolate framework, I push my subgraph schemas to Hive Registry and use Gateway as a router. The issue I'm having right now is that Demand Control seems to ignore the subgraph's @cost and @listsize directives. Also I don't see the changes in Hive Registry regarding them. They're visible in Service tab in Hive but they're omitted in Schema tab. After brief investigation, I have a suspicion that it might be related to Federation version and directives that are available in them. My subgraph schema looks like this: `schema @link(url: "https://specs.apollo.dev/federation/v2.6", import: ["@Shareable", "@external", "@tag", "@key", "@requires", "FieldSet"]) { directive @listsize( Can someone confirm the fact that I need to raise the Federation version link to 2.9 and import directives from Federation spec instead of defining them in order for Demand Control to work? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 2 replies
-
You need to import directives from Federation spec, yes. Gateway does not ignore them, in order to have custom directives in your supergraph, you have to import them using |
Beta Was this translation helpful? Give feedback.
-
Thank you for quick answer, so I'm still a bit confused as after I added these import items by hand (as subgraph library still doesn't support 2.9 spec), I get
from Hive when I'm running schema composition checks. I've downloaded Apollo demo repo and I was getting the same error when using older version of @apollo/subgraph NPM package, after I upgraded it to latest- it started working. It got me thinking: does Hive support this spec? I'm using latest hive-cli. I think the answer is no, looking at the federation-composition package. I can't see any sign of 2.9 spec there. That would mean that using Hive and Federation, there is no possibility to use Demand Control, right? |
Beta Was this translation helpful? Give feedback.
Unfortunately Hive Console doesn't support v2.9 yet. It is on Hive Console's roadmap.
You can treat
@cost
as an additional directive until it is supported by default if you use Hive Console.https://www.apollographql.com/docs/graphos/reference/federation/directives#composedirective