-
Notifications
You must be signed in to change notification settings - Fork 18
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
Add validation compilation phase to ensure federated schema validity #19
Comments
I would refer mostly to the federation spec to determine which kinds of validations we want to enforce are in place https://www.apollographql.com/docs/federation/federation-spec an example would be that object :product do
key_fields("upc")
field :id, non_null(:id)
end Since the field An example compliation validation phase you can reference would be this one from absinthe https://github.com/absinthe-graphql/absinthe/blob/master/lib/absinthe/phase/schema/validation/directives_must_be_valid.ex#L1 |
I'll take this. |
I didn't want to open a new issue since this one covers it. If we add duplicate directives for a field like |
Do we need to verify anything else now? |
There's a validation in Absinthe to ensure that directives not marked as repeatable will return an error when applied multiple times. How does this break for you? |
@maartenvanvliet maybe we run our phases after that validation phase? I wouldn't think we do but we are also doing some weird stuff like hand crafting the directive blueprint structs ourselves because of the lack of support in absinthe which may play into this |
I will try to replicate this in an example repo to demonstrate it when I have a chance. I know that it doesn’t get caught by Apollo’s managed schema checks either, but it breaks IntrospectAndCompose of Federation Gateway since 2.0. |
I pushed the branch where I replicated the issue here: https://github.com/kzlsakal/federation_poc/tree/break-composition If you start the
Here's how it looks like in the schema ( type Product @key(fields: "upc") {
upc: String!
name: String!
price: Int @deprecated(reason: "This field is truly deprecated") @deprecated(reason: "This field is deprecated")
} Here's another example branch with duplicate directives causing the same error on the gateway:
And here's how it looks like in the schema definition: type Product @key(fields: "upc") {
upc: String!
name: String!
price: Int @requires(fields: ["bar"]) @requires(fields: ["foo"])
} |
Absinthe issue to add validation for this absinthe-graphql/absinthe#1177 |
Absinthe 1.7.1 is released with the fix for this. When I run the
So Absinthe now handles this correctly |
It would be great if we had a schema phase that validated the federated aspects of the schema to give end users more insight into why the schema may be an invalid federated schema
The text was updated successfully, but these errors were encountered: