File tree 2 files changed +24
-0
lines changed
2 files changed +24
-0
lines changed Original file line number Diff line number Diff line change @@ -468,6 +468,15 @@ def _add_directive(decl):
468
468
469
469
each (schema .directives , _add_directive )
470
470
471
+ missing_directives = [
472
+ name for name in directive_visitors if name not in declared_directives
473
+ ]
474
+
475
+ if missing_directives :
476
+ raise ValueError (
477
+ f"Missing directive declarations for: { ', ' .join (missing_directives )} "
478
+ )
479
+
471
480
# If the visitor subclass overrides get_directive_declaration, and it
472
481
# returns a non-null GraphQLDirective, use that instead of any directive
473
482
# declared in the schema itself. Reasoning: if a SchemaDirectiveVisitor
Original file line number Diff line number Diff line change @@ -178,6 +178,21 @@ def test_directive_raises_type_error_if_required_argument_is_not_given():
178
178
make_executable_schema (type_defs , directives = {"test" : ReturnValueDirective })
179
179
180
180
181
+ def test_directive_raises_type_error_if_there_is_typo ():
182
+ type_defs = """
183
+ directive @test on FIELD_DEFINITION
184
+
185
+ type Query {
186
+ hello: String! @test,
187
+ }
188
+ """
189
+
190
+ with pytest .raises (ValueError ):
191
+ make_executable_schema (
192
+ type_defs , directives = {"test_typo" : ReturnValueDirective }
193
+ )
194
+
195
+
181
196
def test_can_implement_unique_id_directive ():
182
197
type_defs = """
183
198
directive @uniqueID(name: String, from: [String]) on OBJECT
You can’t perform that action at this time.
0 commit comments