Skip to content

Commit

Permalink
according to the specification, it is not necessary to print unused t…
Browse files Browse the repository at this point in the history
…ypes (in particular scalars)
  • Loading branch information
sungam3r committed Nov 17, 2019
1 parent 22bb008 commit 53127b9
Show file tree
Hide file tree
Showing 8 changed files with 94 additions and 249 deletions.
3 changes: 2 additions & 1 deletion src/GraphQL.ApiTests/ApiApprovalTests.PublicApi.approved.txt
Original file line number Diff line number Diff line change
Expand Up @@ -323,6 +323,7 @@ namespace GraphQL
public static bool IsSubtypeOf(this GraphQL.Types.IGraphType maybeSubType, GraphQL.Types.IGraphType superType, GraphQL.Types.ISchema schema) { }
public static System.Collections.Generic.IEnumerable<string> IsValidLiteralValue(this GraphQL.Types.IGraphType type, GraphQL.Language.AST.IValue valueAst, GraphQL.Types.ISchema schema) { }
public static string NameOf<TSourceType, TProperty>(this System.Linq.Expressions.Expression<System.Func<TSourceType, TProperty>> expression) { }
public static bool References(this GraphQL.Types.ISchema schema, string typeName) { }
public static string TrimGraphQLTypes(this string name) { }
public static TMetadataProvider WithMetadata<TMetadataProvider>(this TMetadataProvider provider, string key, object value)
where TMetadataProvider : GraphQL.Types.IProvideMetadata { }
Expand Down Expand Up @@ -2345,7 +2346,7 @@ namespace GraphQL.Utilities
public class SchemaPrinterOptions
{
public SchemaPrinterOptions() { }
public System.Collections.Generic.List<string> CustomScalars { get; set; }
public bool IncludeAllTypes { get; set; }
public bool IncludeDeprecationReasons { get; set; }
public bool IncludeDescriptions { get; set; }
public bool OldImplementsSyntax { get; set; }
Expand Down
96 changes: 0 additions & 96 deletions src/GraphQL.Tests/Execution/RegisteredInstanceTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -109,42 +109,10 @@ public void build_nested_type_with_list()
query: root
}
scalar BigInt
scalar Byte
scalar Date
scalar DateTime
scalar DateTimeOffset
scalar Decimal
scalar Guid
scalar Long
scalar Milliseconds
type NestedObjType {
intField: Int
}
scalar SByte
scalar Seconds
scalar Short
scalar UInt
scalar ULong
scalar UShort
scalar Uri
type root {
listOfObjField: [NestedObjType]
}
Expand All @@ -158,42 +126,10 @@ public void build_nested_type_with_non_null()
query: root
}
scalar BigInt
scalar Byte
scalar Date
scalar DateTime
scalar DateTimeOffset
scalar Decimal
scalar Guid
scalar Long
scalar Milliseconds
type NestedObjType {
intField: Int
}
scalar SByte
scalar Seconds
scalar Short
scalar UInt
scalar ULong
scalar UShort
scalar Uri
type root {
listOfObjField: NestedObjType!
}
Expand All @@ -207,42 +143,10 @@ public void build_nested_type_with_base()
query: root
}
scalar BigInt
scalar Byte
scalar Date
scalar DateTime
scalar DateTimeOffset
scalar Decimal
scalar Guid
scalar Long
scalar Milliseconds
type NestedObjType {
intField: Int
}
scalar SByte
scalar Seconds
scalar Short
scalar UInt
scalar ULong
scalar UShort
scalar Uri
type root {
listOfObjField: NestedObjType
}
Expand Down
34 changes: 1 addition & 33 deletions src/GraphQL.Tests/Utilities/FederatedSchemaBuilderTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,42 +28,10 @@ public void returns_sdl()

var query = "{ _service { sdl } }";

var sdl = @"scalar BigInt
scalar Byte
scalar Date
scalar DateTime
scalar DateTimeOffset
scalar Decimal
scalar Guid
scalar Long
scalar Milliseconds
extend type Query {
var sdl = @"extend type Query {
me: User
}
scalar SByte
scalar Seconds
scalar Short
scalar UInt
scalar ULong
scalar UShort
scalar Uri
type User @key(fields: ""id"") {
id: ID! @external
username: String!
Expand Down
96 changes: 7 additions & 89 deletions src/GraphQL.Tests/Utilities/SchemaPrinterTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ public class SchemaPrinterTests

private string print(ISchema schema)
{
return print(schema, new SchemaPrinterOptions { IncludeDescriptions = true });
return print(schema, new SchemaPrinterOptions { IncludeDescriptions = true, IncludeAllTypes = true });
}

private string print(ISchema schema, SchemaPrinterOptions options)
Expand Down Expand Up @@ -263,11 +263,12 @@ public void prints_object_field_with_field_descriptions()
var root = new ObjectGraphType { Name = "Query" };
root.Field<FooType>("foo");

var schema = new Schema {Query = root};
var schema = new Schema { Query = root };

var options = new SchemaPrinterOptions
{
IncludeDescriptions = true
IncludeDescriptions = true,
IncludeAllTypes = true
};

var expected = new Dictionary<string, string>
Expand Down Expand Up @@ -298,12 +299,13 @@ public void prints_object_field_with_field_descriptions_and_deprecation_reasons(
var root = new ObjectGraphType { Name = "Query" };
root.Field<FooType>("foo");

var schema = new Schema {Query = root};
var schema = new Schema { Query = root };

var options = new SchemaPrinterOptions
{
IncludeDescriptions = true,
IncludeDeprecationReasons = true
IncludeDeprecationReasons = true,
IncludeAllTypes = true
};

var expected = new Dictionary<string, string>
Expand Down Expand Up @@ -620,57 +622,15 @@ interface Baaz {
str: String
}
scalar BigInt
scalar Byte
# The `Date` scalar type represents a year, month and day in accordance with the
# [ISO-8601](https://en.wikipedia.org/wiki/ISO_8601) standard.
scalar Date
# The `DateTime` scalar type represents a date and time. `DateTime` expects
# timestamps to be formatted in accordance with the
# [ISO-8601](https://en.wikipedia.org/wiki/ISO_8601) standard.
scalar DateTime
# The `DateTimeOffset` scalar type represents a date, time and offset from UTC.
# `DateTimeOffset` expects timestamps to be formatted in accordance with the
# [ISO-8601](https://en.wikipedia.org/wiki/ISO_8601) standard.
scalar DateTimeOffset
scalar Decimal
scalar Guid
# This is a Foo interface type
interface IFoo {
# This is of type String
str: String
}
scalar Long
# The `Milliseconds` scalar type represents a period of time represented as the total number of milliseconds.
scalar Milliseconds
type Query {
bar: Bar
}
scalar SByte
# The `Seconds` scalar type represents a period of time represented as the total number of seconds.
scalar Seconds
scalar Short
scalar UInt
scalar ULong
scalar UShort
scalar Uri
", excludeScalars: true);
}

Expand Down Expand Up @@ -700,57 +660,15 @@ interface Baaz {
str: String
}
scalar BigInt
scalar Byte
# The `Date` scalar type represents a year, month and day in accordance with the
# [ISO-8601](https://en.wikipedia.org/wiki/ISO_8601) standard.
scalar Date
# The `DateTime` scalar type represents a date and time. `DateTime` expects
# timestamps to be formatted in accordance with the
# [ISO-8601](https://en.wikipedia.org/wiki/ISO_8601) standard.
scalar DateTime
# The `DateTimeOffset` scalar type represents a date, time and offset from UTC.
# `DateTimeOffset` expects timestamps to be formatted in accordance with the
# [ISO-8601](https://en.wikipedia.org/wiki/ISO_8601) standard.
scalar DateTimeOffset
scalar Decimal
scalar Guid
# This is a Foo interface type
interface IFoo {
# This is of type String
str: String
}
scalar Long
# The `Milliseconds` scalar type represents a period of time represented as the total number of milliseconds.
scalar Milliseconds
type Query {
bar: Bar
}
scalar SByte
# The `Seconds` scalar type represents a period of time represented as the total number of seconds.
scalar Seconds
scalar Short
scalar UInt
scalar ULong
scalar UShort
scalar Uri
", excludeScalars: true);
}

Expand Down

0 comments on commit 53127b9

Please sign in to comment.