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

Fixed type trimming. The trimmer now correctly visits directives. #4917

Merged
merged 3 commits into from
Apr 14, 2022
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ public IReadOnlyCollection<TypeSystemObjectBase> Trim()
directiveType.Name.Equals(WellKnownDirectives.Deprecated))
{
_touched.Add(directiveType);
VisitDirective(directiveType);
michaelstaib marked this conversation as resolved.
Show resolved Hide resolved
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,42 @@ private void Executable_Directives_Are_Never_Removed_2()
.Resolve("test"))
.AddDirectiveType(new DirectiveType(d => d
.Name("_abc")
.Location(DirectiveLocation.Object| DirectiveLocation.Query)))
.Location(DirectiveLocation.Object | DirectiveLocation.Query)))
.AddType<FloatType>()
.ModifyOptions(o => o.RemoveUnreachableTypes = true)
.Create();

// assert
schema.ToString().MatchSnapshot();
}

[Fact]
private void Executable_Directives_Should_Be_Visited()
{
// arrange
// act
ISchema schema = SchemaBuilder.New()
.AddQueryType(c => c
.Name("abc")
.Field("field")
.Type(new NamedTypeNode("def"))
.Resolve("test"))
.AddInterfaceType(c => c
.Name("def")
.Field("field")
.Type<StringType>())
.AddObjectType(c => c
.Name("ghi")
.Implements(new NamedTypeNode("def"))
.Field("field")
.Type<StringType>()
.Resolve("test"))
.AddType(new UuidType('D'))
.AddDirectiveType(new DirectiveType(d => d
.Name("_abc")
.Location(DirectiveLocation.Object | DirectiveLocation.Query)
.Argument("arg")
.Type<UuidType>()))
.AddType<FloatType>()
.ModifyOptions(o => o.RemoveUnreachableTypes = true)
.Create();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
schema {
query: abc
}

interface def {
field: String
}

type abc {
field: def
}

type ghi implements def {
field: String
}

directive @_abc(arg: UUID) on QUERY | OBJECT

"The `@defer` directive may be provided for fragment spreads and inline fragments to inform the executor to delay the execution of the current fragment to indicate deprioritization of the current fragment. A query with `@defer` directive will cause the request to potentially return multiple responses, where non-deferred data is delivered in the initial response and data deferred is delivered in a subsequent response. `@include` and `@skip` take precedence over `@defer`."
directive @defer("If this argument label has a value other than null, it will be passed on to the result of this defer directive. This label is intended to give client applications a way to identify to which fragment a deferred result belongs to." label: String "Deferred when true." if: Boolean) on FRAGMENT_SPREAD | INLINE_FRAGMENT

"The `@specifiedBy` directive is used within the type system definition language to provide a URL for specifying the behavior of custom scalar definitions."
directive @specifiedBy("The specifiedBy URL points to a human-readable specification. This field will only read a result for scalar types." url: String!) on SCALAR

"The `@stream` directive may be provided for a field of `List` type so that the backend can leverage technology such as asynchronous iterators to provide a partial list in the initial response, and additional list items in subsequent responses. `@include` and `@skip` take precedence over `@stream`."
directive @stream("If this argument label has a value other than null, it will be passed on to the result of this stream directive. This label is intended to give client applications a way to identify to which fragment a streamed result belongs to." label: String "The initial elements that shall be send down to the consumer." initialCount: Int! = 0 "Streamed when true." if: Boolean) on FIELD

scalar UUID @specifiedBy(url: "https:\/\/tools.ietf.org\/html\/rfc4122")