-
Notifications
You must be signed in to change notification settings - Fork 529
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
Allow schema declaration directives #1176
Allow schema declaration directives #1176
Conversation
This is necessary if we want to extend it. It also cleans up some code that checks for the presence of a declaration.
This way it's easier to check for the presence of a declaration when applying type extensions.
This is no longer necessary as every schema has a proper schema declaration struct.
The filtering of the SchemaDeclaration is not necessary here as this is already done in the ApplyDeclaration phase.
@@ -179,8 +183,7 @@ defmodule Absinthe.Schema.TypeSystemDirectiveTest do | |||
end | |||
|
|||
@macro_schema_sdl """ | |||
"Represents a schema" | |||
schema { | |||
schema @feature(name: ":schema") { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this need extend
? or for SDL is it support to declare this without extend?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Turns out that SDL supports it without extend.
This is also covered by validation phases, and with this check the extension of query/mutation/subscription objects is not possible.
For completeness I've also added support for macro based |
Fantastic, thanks! |
Followup to absinthe-graphql#1176 Since every schema will have a declared or inferred declaration, this can be used to mark root objects as referenced. The MarkReferenced used to mark every :query/:subscription/:mutation object as referenced, even when it was used in the declaration. This fix ensures that root objects that are not used in the declaration are not marked as referenced and thus not rendered in the SDL.
In #1140 support was added for applying type system directives in the macro syntax, and in #1157 type extensions became possible in both SDL and macro syntax.
One omission in the above is directives on schema declarations, and applying type extensions on schema declarations. The omission prevents a full implementation of Apollo Federation 2.0 on top of Absinthe. This PR aims to improve on adding the support.
In Absinthe macro schema's it's not necessary to use schema declarations. This stays the same. However, when a type extension is applied to the schema declaration it's necessary for a pre-existing declaration. Therefore, the schema declaration is now inferred from the existing query/mutation/subscription objects. Only in the case of an SDL schema, there can be a pre-existing declaration.
The SDL rendering of blueprint schema's created an ad-hoc schema declaration if no declaration was available. This is no longer necessary.
a97a327 also fixes an issue where the description of the schema declaration was the description of the
__schema
object and not of the schema itself. The__absinthe_schema_declaration__
was added to help out here, and also expose the declaration after the schema is compiled.The
schema do ... end``` was added to the macro syntax, though it will only work in an
extendblock. In a followup a toplevel
schema do ... end` could also work.