diff --git a/src/TestApp/TestStandardLibrary/Generated/GraphQL.g.cs b/src/TestApp/TestStandardLibrary/Generated/GraphQL.g.cs index a6a1181..043e400 100644 --- a/src/TestApp/TestStandardLibrary/Generated/GraphQL.g.cs +++ b/src/TestApp/TestStandardLibrary/Generated/GraphQL.g.cs @@ -1,4 +1,4 @@ -// b212168374f26038cc7200986070affe +// d2b780c89b6d8a786ffdeaaa61bafb2a // This file generated for ZeroQL. // #pragma warning disable 8618 @@ -52,7 +52,7 @@ public class Circle : IFigure, IEntity [JsonPropertyName("creator")] [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] - public Person __Creator { get; set; } + public Person? __Creator { get; set; } [ZeroQL.GraphQLName("creator")] public T? Creator(Func selector = default !) @@ -63,7 +63,7 @@ public class Circle : IFigure, IEntity // This member is not indented to be used. https://github.com/byme8/ZeroQL/issues/58 [JsonIgnore] [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] - IPerson IFigure.__Creator { get; set; } + IPerson? IFigure.__Creator { get; set; } [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] T? IFigure.Creator(Func selector = default !) @@ -225,6 +225,16 @@ public class Mutation : global::ZeroQL.Internal.IMutation return __DateTime; } + [JsonPropertyName("dateTimes")] + [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] + public DateTimeOffset? []? __DateTimes { get; set; } + + [ZeroQL.GraphQLName("dateTimes")] + public DateTimeOffset?[]? DateTimes([ZeroQL.GraphQLType("[DateTime]")] DateTimeOffset[]? dateTime = default !) + { + return __DateTimes; + } + [JsonPropertyName("dateTimeOffset")] [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] public DateTimeOffset __DateTimeOffset { get; set; } @@ -341,7 +351,7 @@ public class Mutation : global::ZeroQL.Internal.IMutation [JsonPropertyName("addLimitNullable")] [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] - public LimitZeroQL __AddLimitNullable { get; set; } + public LimitZeroQL? __AddLimitNullable { get; set; } [ZeroQL.GraphQLName("addLimitNullable")] public T? AddLimitNullable([ZeroQL.GraphQLType("LimitInput")] LimitInputZeroQL? limit = default !, Func selector = default !) @@ -361,7 +371,7 @@ public class Mutation : global::ZeroQL.Internal.IMutation [JsonPropertyName("addLimit2Nullable")] [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] - public Limit2ZeroQL __AddLimit2Nullable { get; set; } + public Limit2ZeroQL? __AddLimit2Nullable { get; set; } [ZeroQL.GraphQLName("addLimit2Nullable")] public T? AddLimit2Nullable([ZeroQL.GraphQLType("Limit2Input")] Limit2Input? limit = default !, Func selector = default !) @@ -371,7 +381,7 @@ public class Mutation : global::ZeroQL.Internal.IMutation [JsonPropertyName("addLimit3")] [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] - public Limit3 __AddLimit3 { get; set; } + public Limit3? __AddLimit3 { get; set; } [ZeroQL.GraphQLName("addLimit3")] public T? AddLimit3([ZeroQL.GraphQLType("Limit3Input")] Limit3InputZeroQL? limit = default !, Func selector = default !) @@ -480,7 +490,7 @@ public class Point : IFigure, IEntity // This member is not indented to be used. https://github.com/byme8/ZeroQL/issues/58 [JsonIgnore] [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] - IPerson IFigure.__Creator { get; set; } + IPerson? IFigure.__Creator { get; set; } [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] T? IFigure.Creator(Func selector = default !) @@ -677,7 +687,7 @@ public class Query : global::ZeroQL.Internal.IQuery [JsonPropertyName("user")] [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] - public User __User { get; set; } + public User? __User { get; set; } [ZeroQL.GraphQLName("user")] public T? User([ZeroQL.GraphQLType("Int!")] int id = default !, Func selector = default !) @@ -707,7 +717,7 @@ public class Query : global::ZeroQL.Internal.IQuery [JsonPropertyName("admin")] [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] - public User __Admin { get; set; } + public User? __Admin { get; set; } [ZeroQL.GraphQLName("admin")] public T? Admin([ZeroQL.GraphQLType("Int!")] int id = default !, Func selector = default !) @@ -807,7 +817,7 @@ public class Square : IFigure, IEntity [JsonPropertyName("creator")] [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] - public IPerson __Creator { get; set; } + public IPerson? __Creator { get; set; } [ZeroQL.GraphQLName("creator")] public T? Creator(Func selector = default !) @@ -963,7 +973,7 @@ public class TypesContainer [JsonPropertyName("value28")] [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] - public KeyValuePairOfStringAndString[] __Value28 { get; set; } + public KeyValuePairOfStringAndString[]? __Value28 { get; set; } [ZeroQL.GraphQLName("value28")] public T[]? Value28(Func selector = default !) @@ -983,7 +993,7 @@ public class TypesContainer [JsonPropertyName("value30")] [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] - public KeyValuePairOfStringAndString __Value30 { get; set; } + public KeyValuePairOfStringAndString? __Value30 { get; set; } [ZeroQL.GraphQLName("value30")] public T? Value30(Func selector = default !) @@ -1022,7 +1032,7 @@ public class User [JsonPropertyName("role")] [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] - public Role __Role { get; set; } + public Role? __Role { get; set; } [ZeroQL.GraphQLName("role")] public T? Role(Func selector = default !) @@ -1060,7 +1070,7 @@ public interface IFigure : global::ZeroQL.IUnionType [JsonPropertyName("creator")] [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] - public IPerson __Creator { get; set; } + public IPerson? __Creator { get; set; } [ZeroQL.GraphQLName("creator")] public T? Creator(Func selector = default !); @@ -1079,7 +1089,7 @@ public class IFigureStub : IFigure [JsonPropertyName("creator")] [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] - public IPerson __Creator { get; set; } + public IPerson? __Creator { get; set; } [ZeroQL.GraphQLName("creator")] public T? Creator(Func selector = default !) diff --git a/src/TestApp/ZeroQL.TestApp/Generated/GraphQL.g.cs b/src/TestApp/ZeroQL.TestApp/Generated/GraphQL.g.cs index 50ca81d..29da07f 100644 --- a/src/TestApp/ZeroQL.TestApp/Generated/GraphQL.g.cs +++ b/src/TestApp/ZeroQL.TestApp/Generated/GraphQL.g.cs @@ -1,4 +1,4 @@ -// ecce768958de6d75a0825a7322c84587 +// 13f414ba7b9b7b647d5105e3b9697837 // This file generated for ZeroQL. // #pragma warning disable 8618 @@ -52,7 +52,7 @@ public class Circle : IFigure, IEntity [JsonPropertyName("creator")] [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] - public Person __Creator { get; set; } + public Person? __Creator { get; set; } [ZeroQL.GraphQLName("creator")] public T? Creator(Func selector = default !) @@ -63,7 +63,7 @@ public class Circle : IFigure, IEntity // This member is not indented to be used. https://github.com/byme8/ZeroQL/issues/58 [JsonIgnore] [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] - IPerson IFigure.__Creator { get; set; } + IPerson? IFigure.__Creator { get; set; } [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] T? IFigure.Creator(Func selector = default !) @@ -225,6 +225,16 @@ public class Mutation : global::ZeroQL.Internal.IMutation return __DateTime; } + [JsonPropertyName("dateTimes")] + [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] + public DateTimeOffset? []? __DateTimes { get; set; } + + [ZeroQL.GraphQLName("dateTimes")] + public DateTimeOffset?[]? DateTimes([ZeroQL.GraphQLType("[DateTime]")] DateTimeOffset[]? dateTime = default !) + { + return __DateTimes; + } + [JsonPropertyName("dateTimeOffset")] [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] public DateTimeOffset __DateTimeOffset { get; set; } @@ -341,7 +351,7 @@ public class Mutation : global::ZeroQL.Internal.IMutation [JsonPropertyName("addLimitNullable")] [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] - public LimitZeroQL __AddLimitNullable { get; set; } + public LimitZeroQL? __AddLimitNullable { get; set; } [ZeroQL.GraphQLName("addLimitNullable")] public T? AddLimitNullable([ZeroQL.GraphQLType("LimitInput")] LimitInputZeroQL? limit = default !, Func selector = default !) @@ -361,7 +371,7 @@ public class Mutation : global::ZeroQL.Internal.IMutation [JsonPropertyName("addLimit2Nullable")] [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] - public Limit2ZeroQL __AddLimit2Nullable { get; set; } + public Limit2ZeroQL? __AddLimit2Nullable { get; set; } [ZeroQL.GraphQLName("addLimit2Nullable")] public T? AddLimit2Nullable([ZeroQL.GraphQLType("Limit2Input")] Limit2Input? limit = default !, Func selector = default !) @@ -371,7 +381,7 @@ public class Mutation : global::ZeroQL.Internal.IMutation [JsonPropertyName("addLimit3")] [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] - public Limit3 __AddLimit3 { get; set; } + public Limit3? __AddLimit3 { get; set; } [ZeroQL.GraphQLName("addLimit3")] public T? AddLimit3([ZeroQL.GraphQLType("Limit3Input")] Limit3InputZeroQL? limit = default !, Func selector = default !) @@ -480,7 +490,7 @@ public class Point : IFigure, IEntity // This member is not indented to be used. https://github.com/byme8/ZeroQL/issues/58 [JsonIgnore] [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] - IPerson IFigure.__Creator { get; set; } + IPerson? IFigure.__Creator { get; set; } [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] T? IFigure.Creator(Func selector = default !) @@ -677,7 +687,7 @@ public class Query : global::ZeroQL.Internal.IQuery [JsonPropertyName("user")] [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] - public User __User { get; set; } + public User? __User { get; set; } [ZeroQL.GraphQLName("user")] public T? User([ZeroQL.GraphQLType("Int!")] int id = default !, Func selector = default !) @@ -707,7 +717,7 @@ public class Query : global::ZeroQL.Internal.IQuery [JsonPropertyName("admin")] [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] - public User __Admin { get; set; } + public User? __Admin { get; set; } [ZeroQL.GraphQLName("admin")] public T? Admin([ZeroQL.GraphQLType("Int!")] int id = default !, Func selector = default !) @@ -807,7 +817,7 @@ public class Square : IFigure, IEntity [JsonPropertyName("creator")] [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] - public IPerson __Creator { get; set; } + public IPerson? __Creator { get; set; } [ZeroQL.GraphQLName("creator")] public T? Creator(Func selector = default !) @@ -963,7 +973,7 @@ public class TypesContainer [JsonPropertyName("value28")] [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] - public KeyValuePairOfStringAndString[] __Value28 { get; set; } + public KeyValuePairOfStringAndString[]? __Value28 { get; set; } [ZeroQL.GraphQLName("value28")] public T[]? Value28(Func selector = default !) @@ -983,7 +993,7 @@ public class TypesContainer [JsonPropertyName("value30")] [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] - public KeyValuePairOfStringAndString __Value30 { get; set; } + public KeyValuePairOfStringAndString? __Value30 { get; set; } [ZeroQL.GraphQLName("value30")] public T? Value30(Func selector = default !) @@ -1022,7 +1032,7 @@ public class User [JsonPropertyName("role")] [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] - public Role __Role { get; set; } + public Role? __Role { get; set; } [ZeroQL.GraphQLName("role")] public T? Role(Func selector = default !) @@ -1060,7 +1070,7 @@ public interface IFigure : global::ZeroQL.IUnionType [JsonPropertyName("creator")] [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] - public IPerson __Creator { get; set; } + public IPerson? __Creator { get; set; } [ZeroQL.GraphQLName("creator")] public T? Creator(Func selector = default !); @@ -1079,7 +1089,7 @@ public class IFigureStub : IFigure [JsonPropertyName("creator")] [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] - public IPerson __Creator { get; set; } + public IPerson? __Creator { get; set; } [ZeroQL.GraphQLName("creator")] public T? Creator(Func selector = default !) diff --git a/src/TestApp/ZeroQL.TestApp/schema.graphql b/src/TestApp/ZeroQL.TestApp/schema.graphql index 419394b..0ff2b0f 100644 --- a/src/TestApp/ZeroQL.TestApp/schema.graphql +++ b/src/TestApp/ZeroQL.TestApp/schema.graphql @@ -70,6 +70,7 @@ type Limit3 { type Mutation { createInstant(instant: Instant!): Instant! dateTime(dateTime: DateTime!): DateTime! + dateTimes(dateTime: [DateTime]): [DateTime] dateTimeOffset(dateTimeOffset: DateTime!): DateTime! timeSpan(timeSpan: TimeSpan!): TimeSpan! dateOnly(dateOnly: Date!): Date! diff --git a/src/ZeroQL.TestServer/Query/DateMutation.cs b/src/ZeroQL.TestServer/Query/DateMutation.cs index 03b6bb1..f7e67a4 100644 --- a/src/ZeroQL.TestServer/Query/DateMutation.cs +++ b/src/ZeroQL.TestServer/Query/DateMutation.cs @@ -5,6 +5,8 @@ public class DateMutation { public DateTime GetDateTime(DateTime dateTime) => dateTime; + public DateTime?[]? GetDateTimes(DateTime?[]? dateTime) => dateTime; + public DateTimeOffset GetDateTimeOffset(DateTimeOffset dateTimeOffset) => dateTimeOffset; public TimeSpan GetTimeSpan(TimeSpan timeSpan) => timeSpan; diff --git a/src/ZeroQL.Tests/Bootstrap/ParseSchemaTests.InternalClient.verified.txt b/src/ZeroQL.Tests/Bootstrap/ParseSchemaTests.InternalClient.verified.txt index 52ab74f..2ef474c 100644 --- a/src/ZeroQL.Tests/Bootstrap/ParseSchemaTests.InternalClient.verified.txt +++ b/src/ZeroQL.Tests/Bootstrap/ParseSchemaTests.InternalClient.verified.txt @@ -52,7 +52,7 @@ namespace GraphQLClient [JsonPropertyName("creator")] [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] - public Person __Creator { get; set; } + public Person? __Creator { get; set; } [ZeroQL.GraphQLName("creator")] public T? Creator(Func selector = default !) @@ -63,7 +63,7 @@ namespace GraphQLClient // This member is not indented to be used. https://github.com/byme8/ZeroQL/issues/58 [JsonIgnore] [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] - IPerson IFigure.__Creator { get; set; } + IPerson? IFigure.__Creator { get; set; } [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] T? IFigure.Creator(Func selector = default !) @@ -225,6 +225,16 @@ namespace GraphQLClient return __DateTime; } + [JsonPropertyName("dateTimes")] + [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] + public DateTimeOffset? []? __DateTimes { get; set; } + + [ZeroQL.GraphQLName("dateTimes")] + public DateTimeOffset?[]? DateTimes([ZeroQL.GraphQLType("[DateTime]")] DateTimeOffset[]? dateTime = default !) + { + return __DateTimes; + } + [JsonPropertyName("dateTimeOffset")] [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] public DateTimeOffset __DateTimeOffset { get; set; } @@ -341,7 +351,7 @@ namespace GraphQLClient [JsonPropertyName("addLimitNullable")] [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] - public LimitZeroQL __AddLimitNullable { get; set; } + public LimitZeroQL? __AddLimitNullable { get; set; } [ZeroQL.GraphQLName("addLimitNullable")] public T? AddLimitNullable([ZeroQL.GraphQLType("LimitInput")] LimitInputZeroQL? limit = default !, Func selector = default !) @@ -361,7 +371,7 @@ namespace GraphQLClient [JsonPropertyName("addLimit2Nullable")] [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] - public Limit2ZeroQL __AddLimit2Nullable { get; set; } + public Limit2ZeroQL? __AddLimit2Nullable { get; set; } [ZeroQL.GraphQLName("addLimit2Nullable")] public T? AddLimit2Nullable([ZeroQL.GraphQLType("Limit2Input")] Limit2Input? limit = default !, Func selector = default !) @@ -371,7 +381,7 @@ namespace GraphQLClient [JsonPropertyName("addLimit3")] [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] - public Limit3 __AddLimit3 { get; set; } + public Limit3? __AddLimit3 { get; set; } [ZeroQL.GraphQLName("addLimit3")] public T? AddLimit3([ZeroQL.GraphQLType("Limit3Input")] Limit3InputZeroQL? limit = default !, Func selector = default !) @@ -480,7 +490,7 @@ namespace GraphQLClient // This member is not indented to be used. https://github.com/byme8/ZeroQL/issues/58 [JsonIgnore] [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] - IPerson IFigure.__Creator { get; set; } + IPerson? IFigure.__Creator { get; set; } [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] T? IFigure.Creator(Func selector = default !) @@ -677,7 +687,7 @@ namespace GraphQLClient [JsonPropertyName("user")] [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] - public User __User { get; set; } + public User? __User { get; set; } [ZeroQL.GraphQLName("user")] public T? User([ZeroQL.GraphQLType("Int!")] int id = default !, Func selector = default !) @@ -707,7 +717,7 @@ namespace GraphQLClient [JsonPropertyName("admin")] [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] - public User __Admin { get; set; } + public User? __Admin { get; set; } [ZeroQL.GraphQLName("admin")] public T? Admin([ZeroQL.GraphQLType("Int!")] int id = default !, Func selector = default !) @@ -807,7 +817,7 @@ namespace GraphQLClient [JsonPropertyName("creator")] [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] - public IPerson __Creator { get; set; } + public IPerson? __Creator { get; set; } [ZeroQL.GraphQLName("creator")] public T? Creator(Func selector = default !) @@ -963,7 +973,7 @@ namespace GraphQLClient [JsonPropertyName("value28")] [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] - public KeyValuePairOfStringAndString[] __Value28 { get; set; } + public KeyValuePairOfStringAndString[]? __Value28 { get; set; } [ZeroQL.GraphQLName("value28")] public T[]? Value28(Func selector = default !) @@ -983,7 +993,7 @@ namespace GraphQLClient [JsonPropertyName("value30")] [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] - public KeyValuePairOfStringAndString __Value30 { get; set; } + public KeyValuePairOfStringAndString? __Value30 { get; set; } [ZeroQL.GraphQLName("value30")] public T? Value30(Func selector = default !) @@ -1022,7 +1032,7 @@ namespace GraphQLClient [JsonPropertyName("role")] [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] - public Role __Role { get; set; } + public Role? __Role { get; set; } [ZeroQL.GraphQLName("role")] public T? Role(Func selector = default !) @@ -1060,7 +1070,7 @@ namespace GraphQLClient [JsonPropertyName("creator")] [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] - public IPerson __Creator { get; set; } + public IPerson? __Creator { get; set; } [ZeroQL.GraphQLName("creator")] public T? Creator(Func selector = default !); @@ -1079,7 +1089,7 @@ namespace GraphQLClient [JsonPropertyName("creator")] [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] - public IPerson __Creator { get; set; } + public IPerson? __Creator { get; set; } [ZeroQL.GraphQLName("creator")] public T? Creator(Func selector = default !) diff --git a/src/ZeroQL.Tests/Bootstrap/ParseSchemaTests.MutationDetected.verified.txt b/src/ZeroQL.Tests/Bootstrap/ParseSchemaTests.MutationDetected.verified.txt index ef4846c..fe40a7f 100644 --- a/src/ZeroQL.Tests/Bootstrap/ParseSchemaTests.MutationDetected.verified.txt +++ b/src/ZeroQL.Tests/Bootstrap/ParseSchemaTests.MutationDetected.verified.txt @@ -1,6 +1,7 @@ [ global::ZeroQL.Instant CreateInstant([ZeroQL.GraphQLType("Instant!")] global::ZeroQL.Instant instant = default !), DateTimeOffset DateTime([ZeroQL.GraphQLType("DateTime!")] DateTimeOffset dateTime = default !), + DateTimeOffset?[]? DateTimes([ZeroQL.GraphQLType("[DateTime]")] DateTimeOffset[]? dateTime = default !), DateTimeOffset DateTimeOffset([ZeroQL.GraphQLType("DateTime!")] DateTimeOffset dateTimeOffset = default !), TimeSpan TimeSpan([ZeroQL.GraphQLType("TimeSpan!")] TimeSpan timeSpan = default !), DateOnly DateOnly([ZeroQL.GraphQLType("Date!")] DateOnly dateOnly = default !), diff --git a/src/ZeroQL.Tests/Bootstrap/ParseSchemaTests.PublicClient.verified.txt b/src/ZeroQL.Tests/Bootstrap/ParseSchemaTests.PublicClient.verified.txt index 8693b8b..f441f7b 100644 --- a/src/ZeroQL.Tests/Bootstrap/ParseSchemaTests.PublicClient.verified.txt +++ b/src/ZeroQL.Tests/Bootstrap/ParseSchemaTests.PublicClient.verified.txt @@ -52,7 +52,7 @@ namespace GraphQLClient [JsonPropertyName("creator")] [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] - public Person __Creator { get; set; } + public Person? __Creator { get; set; } [ZeroQL.GraphQLName("creator")] public T? Creator(Func selector = default !) @@ -63,7 +63,7 @@ namespace GraphQLClient // This member is not indented to be used. https://github.com/byme8/ZeroQL/issues/58 [JsonIgnore] [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] - IPerson IFigure.__Creator { get; set; } + IPerson? IFigure.__Creator { get; set; } [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] T? IFigure.Creator(Func selector = default !) @@ -225,6 +225,16 @@ namespace GraphQLClient return __DateTime; } + [JsonPropertyName("dateTimes")] + [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] + public DateTimeOffset? []? __DateTimes { get; set; } + + [ZeroQL.GraphQLName("dateTimes")] + public DateTimeOffset?[]? DateTimes([ZeroQL.GraphQLType("[DateTime]")] DateTimeOffset[]? dateTime = default !) + { + return __DateTimes; + } + [JsonPropertyName("dateTimeOffset")] [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] public DateTimeOffset __DateTimeOffset { get; set; } @@ -341,7 +351,7 @@ namespace GraphQLClient [JsonPropertyName("addLimitNullable")] [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] - public LimitZeroQL __AddLimitNullable { get; set; } + public LimitZeroQL? __AddLimitNullable { get; set; } [ZeroQL.GraphQLName("addLimitNullable")] public T? AddLimitNullable([ZeroQL.GraphQLType("LimitInput")] LimitInputZeroQL? limit = default !, Func selector = default !) @@ -361,7 +371,7 @@ namespace GraphQLClient [JsonPropertyName("addLimit2Nullable")] [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] - public Limit2ZeroQL __AddLimit2Nullable { get; set; } + public Limit2ZeroQL? __AddLimit2Nullable { get; set; } [ZeroQL.GraphQLName("addLimit2Nullable")] public T? AddLimit2Nullable([ZeroQL.GraphQLType("Limit2Input")] Limit2Input? limit = default !, Func selector = default !) @@ -371,7 +381,7 @@ namespace GraphQLClient [JsonPropertyName("addLimit3")] [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] - public Limit3 __AddLimit3 { get; set; } + public Limit3? __AddLimit3 { get; set; } [ZeroQL.GraphQLName("addLimit3")] public T? AddLimit3([ZeroQL.GraphQLType("Limit3Input")] Limit3InputZeroQL? limit = default !, Func selector = default !) @@ -480,7 +490,7 @@ namespace GraphQLClient // This member is not indented to be used. https://github.com/byme8/ZeroQL/issues/58 [JsonIgnore] [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] - IPerson IFigure.__Creator { get; set; } + IPerson? IFigure.__Creator { get; set; } [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] T? IFigure.Creator(Func selector = default !) @@ -677,7 +687,7 @@ namespace GraphQLClient [JsonPropertyName("user")] [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] - public User __User { get; set; } + public User? __User { get; set; } [ZeroQL.GraphQLName("user")] public T? User([ZeroQL.GraphQLType("Int!")] int id = default !, Func selector = default !) @@ -707,7 +717,7 @@ namespace GraphQLClient [JsonPropertyName("admin")] [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] - public User __Admin { get; set; } + public User? __Admin { get; set; } [ZeroQL.GraphQLName("admin")] public T? Admin([ZeroQL.GraphQLType("Int!")] int id = default !, Func selector = default !) @@ -807,7 +817,7 @@ namespace GraphQLClient [JsonPropertyName("creator")] [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] - public IPerson __Creator { get; set; } + public IPerson? __Creator { get; set; } [ZeroQL.GraphQLName("creator")] public T? Creator(Func selector = default !) @@ -963,7 +973,7 @@ namespace GraphQLClient [JsonPropertyName("value28")] [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] - public KeyValuePairOfStringAndString[] __Value28 { get; set; } + public KeyValuePairOfStringAndString[]? __Value28 { get; set; } [ZeroQL.GraphQLName("value28")] public T[]? Value28(Func selector = default !) @@ -983,7 +993,7 @@ namespace GraphQLClient [JsonPropertyName("value30")] [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] - public KeyValuePairOfStringAndString __Value30 { get; set; } + public KeyValuePairOfStringAndString? __Value30 { get; set; } [ZeroQL.GraphQLName("value30")] public T? Value30(Func selector = default !) @@ -1022,7 +1032,7 @@ namespace GraphQLClient [JsonPropertyName("role")] [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] - public Role __Role { get; set; } + public Role? __Role { get; set; } [ZeroQL.GraphQLName("role")] public T? Role(Func selector = default !) @@ -1060,7 +1070,7 @@ namespace GraphQLClient [JsonPropertyName("creator")] [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] - public IPerson __Creator { get; set; } + public IPerson? __Creator { get; set; } [ZeroQL.GraphQLName("creator")] public T? Creator(Func selector = default !); @@ -1079,7 +1089,7 @@ namespace GraphQLClient [JsonPropertyName("creator")] [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] - public IPerson __Creator { get; set; } + public IPerson? __Creator { get; set; } [ZeroQL.GraphQLName("creator")] public T? Creator(Func selector = default !) diff --git a/src/ZeroQL.Tests/CLI/CliTests.CanPullSchemaFromRemoteServer.verified.txt b/src/ZeroQL.Tests/CLI/CliTests.CanPullSchemaFromRemoteServer.verified.txt index caf27e6..1e2d3a1 100644 --- a/src/ZeroQL.Tests/CLI/CliTests.CanPullSchemaFromRemoteServer.verified.txt +++ b/src/ZeroQL.Tests/CLI/CliTests.CanPullSchemaFromRemoteServer.verified.txt @@ -50,6 +50,7 @@ type Query { type Mutation { createInstant(instant: Instant!): Instant! dateTime(dateTime: DateTime!): DateTime! + dateTimes(dateTime: [DateTime]): [DateTime] dateTimeOffset(dateTimeOffset: DateTime!): DateTime! timeSpan(timeSpan: TimeSpan!): TimeSpan! dateOnly(dateOnly: Date!): Date! diff --git a/src/ZeroQL.Tests/SourceGeneration/DateTests.Dates_name=DateTimes.verified.txt b/src/ZeroQL.Tests/SourceGeneration/DateTests.Dates_name=DateTimes.verified.txt new file mode 100644 index 0000000..12122d3 --- /dev/null +++ b/src/ZeroQL.Tests/SourceGeneration/DateTests.Dates_name=DateTimes.verified.txt @@ -0,0 +1,6 @@ +{ + Query: mutation ($input: [DateTime!]!) { dateTimes(dateTime: $input)}, + Data: [ + 2042-12-11 09:09:08.007 +0 + ] +} \ No newline at end of file diff --git a/src/ZeroQL.Tests/SourceGeneration/DateTests.cs b/src/ZeroQL.Tests/SourceGeneration/DateTests.cs index 361ff45..6979f46 100644 --- a/src/ZeroQL.Tests/SourceGeneration/DateTests.cs +++ b/src/ZeroQL.Tests/SourceGeneration/DateTests.cs @@ -8,6 +8,7 @@ public class DateTests : IntegrationTest { [Theory] [InlineData("DateTime", "new DateTime(2042, 12, 11, 10, 9, 8, 7)")] + [InlineData("DateTimes", "new [] { new DateTimeOffset(2042, 12, 11, 10, 9, 8, 7, TimeSpan.FromHours(1)) }")] [InlineData("DateTimeOffset", "new DateTimeOffset(2042, 12, 11, 10, 9, 8, 7, TimeSpan.FromHours(1))")] [InlineData("TimeSpan", "new TimeSpan(7, 6, 5, 4, 3)")] [InlineData("DateOnly", "new DateOnly(2042, 12, 11)")] diff --git a/src/ZeroQL.Tools/Bootstrap/Generators/TypeGenerator.cs b/src/ZeroQL.Tools/Bootstrap/Generators/TypeGenerator.cs index f15f11d..f239339 100644 --- a/src/ZeroQL.Tools/Bootstrap/Generators/TypeGenerator.cs +++ b/src/ZeroQL.Tools/Bootstrap/Generators/TypeGenerator.cs @@ -140,7 +140,7 @@ public static ClassDeclarationSyntax[] GenerateInputs( { var fields = o.Properties .Select(property => - CSharpHelper.Property(property.Name, property.TypeDefinition, true, property.DefaultValue) + CSharpHelper.Property(property.Name, property.TypeDefinition, property.DefaultValue) .AddAttributeWithStringParameter(ZeroQLGenerationInfo.JsonPropertyNameAttribute, property.GraphQLName) .AddAttributeWithStringParameter(ZeroQLGenerationInfo.GraphQLNameAttribute, @@ -157,7 +157,7 @@ public static ClassDeclarationSyntax[] GenerateInputs( private static PropertyDeclarationSyntax BackedField(FieldDefinition field) { return CSharpHelper - .Property("__" + field.Name, field.TypeDefinition, false, null) + .Property("__" + field.Name, field.TypeDefinition, null) .AddAttributeWithStringParameter( ZeroQLGenerationInfo.JsonPropertyNameAttribute, field.GraphQLName) .AddAttributeWithRawParameters( @@ -187,7 +187,7 @@ public static MemberDeclarationSyntax[] GeneratePropertiesDeclarations(this Fiel } var property = CSharpHelper - .Property(field.Name, field.TypeDefinition, true, field.DefaultValue) + .Property(field.Name, field.TypeDefinition, field.DefaultValue) .AddAttributeWithStringParameter(ZeroQLGenerationInfo.GraphQLNameAttribute, field.GraphQLName) .AddAttributeWithStringParameter(ZeroQLGenerationInfo.JsonPropertyNameAttribute, field.GraphQLName); @@ -203,7 +203,7 @@ private static MemberDeclarationSyntax GenerateQueryPropertyDeclaration( ParameterSyntax[] parameters, bool interfaceField = false) { - var returnType = GetPropertyReturnType(field.TypeDefinition); + var returnType = CSharpHelper.GetPropertyType(field.TypeDefinition, true); var name = GetPropertyName(field.Name, field.TypeDefinition); var funcType = GetPropertyFuncType(field.TypeDefinition, true); @@ -340,22 +340,7 @@ private static string GetPropertyMethodBody(string fieldName, } } - private static string GetPropertyReturnType(TypeDefinition typeDefinition) - { - switch (typeDefinition) - { - case ObjectTypeDefinition type: - return "T" + type.NullableAnnotation(); - case ScalarTypeDefinition type: - return type.NameWithNullableAnnotation(); - case EnumTypeDefinition type: - return type.NameWithNullableAnnotation(); - case ListTypeDefinition type: - return $"{GetPropertyReturnType(type.ElementTypeDefinition)}[]{type.NullableAnnotation()}"; - default: - throw new NotImplementedException(); - } - } + private static string? GetDefaultValue(GraphQLInputValueDefinition field) { diff --git a/src/ZeroQL.Tools/Internal/CSharpHelper.cs b/src/ZeroQL.Tools/Internal/CSharpHelper.cs index efe0d6b..8cd2056 100644 --- a/src/ZeroQL.Tools/Internal/CSharpHelper.cs +++ b/src/ZeroQL.Tools/Internal/CSharpHelper.cs @@ -1,4 +1,5 @@ -using System.Globalization; +using System; +using System.Globalization; using System.Linq; using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis.CSharp; @@ -56,10 +57,9 @@ public static T AddAttributeWithStringParameter(this T declarationSyntax, str .AddAttributes(attribute)); } - public static PropertyDeclarationSyntax Property(string name, TypeDefinition type, bool withNullableAnnotation, - string? defaultValue) + public static PropertyDeclarationSyntax Property(string name, TypeDefinition type, string? defaultValue) { - var fullTypeName = withNullableAnnotation ? type.NameWithNullableAnnotation() : type.Name; + var fullTypeName = GetPropertyType(type, false); var propertyDeclarationSyntax = PropertyDeclaration(ParseTypeName(fullTypeName), Identifier(name)) .AddModifiers(Token(SyntaxKind.PublicKeyword)) @@ -82,7 +82,24 @@ public static PropertyDeclarationSyntax Property(string name, TypeDefinition typ return propertyDeclarationSyntax; } - + + public static string GetPropertyType(TypeDefinition typeDefinition, bool generic) + { + switch (typeDefinition) + { + case ObjectTypeDefinition type: + var typeName = generic ? "T" : type.Name; + return typeName + type.NullableAnnotation(); + case ScalarTypeDefinition type: + return type.NameWithNullableAnnotation(); + case EnumTypeDefinition type: + return type.NameWithNullableAnnotation(); + case ListTypeDefinition type: + return $"{GetPropertyType(type.ElementTypeDefinition, generic)}[]{type.NullableAnnotation()}"; + default: + throw new NotImplementedException(); + } + } private static ExpressionSyntax? GetInitializerExpression(TypeDefinition type, string? strValue) => type.Name switch { diff --git a/src/ZeroQL.Tools/Schema/GraphQLType.cs b/src/ZeroQL.Tools/Schema/GraphQLType.cs index a7173e1..2cfe31f 100644 --- a/src/ZeroQL.Tools/Schema/GraphQLType.cs +++ b/src/ZeroQL.Tools/Schema/GraphQLType.cs @@ -13,48 +13,16 @@ public static string NullableAnnotation(this TypeDefinition type) } } -public abstract record TypeDefinition -{ - protected TypeDefinition(string name, bool canBeNull) - { - Name = name; - CanBeNull = canBeNull; - } - - public string Name { get; init; } - - public bool CanBeNull { get; init; } -} - -public record ScalarTypeDefinition : TypeDefinition -{ - public ScalarTypeDefinition(string name) - : base(name, false) - { - } -} +public abstract record TypeDefinition(string Name, bool CanBeNull); -public record EnumTypeDefinition : TypeDefinition -{ - public EnumTypeDefinition(string name) - : base(name, false) - { - } -} +public record ScalarTypeDefinition(string Name) : + TypeDefinition(Name, false); -public record ObjectTypeDefinition : TypeDefinition -{ - public ObjectTypeDefinition(string name) : base(name, false) - { - } -} +public record EnumTypeDefinition(string Name) + : TypeDefinition(Name, false); -public record ListTypeDefinition : TypeDefinition -{ - public ListTypeDefinition(string name, bool canBeNull, TypeDefinition elementTypeDefinition) : base(name, canBeNull) - { - ElementTypeDefinition = elementTypeDefinition; - } +public record ObjectTypeDefinition(string Name) + : TypeDefinition(Name, false); - public TypeDefinition ElementTypeDefinition { get; init; } -} \ No newline at end of file +public record ListTypeDefinition(string Name, bool CanBeNull, TypeDefinition ElementTypeDefinition) + : TypeDefinition(Name, CanBeNull); \ No newline at end of file