Skip to content

Commit 43411a9

Browse files
committed
First pass at adding long values to spec parsing
1 parent e257114 commit 43411a9

File tree

3 files changed

+20
-5
lines changed

3 files changed

+20
-5
lines changed

Octokit.GraphQL.Core.Generation/Models/TypeModel.cs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,15 @@ public static TypeModel Int()
6868
};
6969
}
7070

71+
public static TypeModel Long()
72+
{
73+
return new TypeModel
74+
{
75+
Kind = TypeKind.Scalar,
76+
Name = "Long",
77+
};
78+
}
79+
7180
public static TypeModel ID()
7281
{
7382
return new TypeModel

Octokit.GraphQL.Core.Generation/Utilities/TypeUtilities.cs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ internal static object GetArgName(InputValueModel arg)
6666

6767
public static bool IsCSharpPrimitive(TypeModel type)
6868
{
69-
return type.Kind == TypeKind.Scalar ||
69+
return type.Kind == TypeKind.Scalar ||
7070
type.Kind == TypeKind.Enum ||
7171
(type.Kind == TypeKind.NonNull && IsCSharpPrimitive(type.OfType));
7272
}
@@ -113,7 +113,7 @@ public static TypeModel ReduceType(TypeModel type)
113113

114114
return type;
115115
}
116-
116+
117117
public static string GetGraphQlIdentifierAttribute(string graphQlModelType)
118118
{
119119
if (graphQlModelType == null)
@@ -133,6 +133,7 @@ private static string GetCSharpType(TypeModel type, bool nullableType, bool retu
133133
switch (type.Name)
134134
{
135135
case "Int": return "int" + question;
136+
case "Long": return "long" + question;
136137
case "Float": return "double" + question;
137138
case "String": return "string";
138139
case "Boolean": return "bool" + question;
@@ -162,10 +163,11 @@ private static string GetCSharpType(TypeModel type, bool nullableType, bool retu
162163
private static bool IsValueType(TypeModel type)
163164
{
164165
return type.Kind == TypeKind.Enum ||
165-
(type.Kind == TypeKind.Scalar &&
166+
(type.Kind == TypeKind.Scalar &&
166167
(type.Name == "Int" ||
167-
type.Name == "Float" ||
168-
type.Name == "Boolean" ||
168+
type.Name == "Long" ||
169+
type.Name == "Float" ||
170+
type.Name == "Boolean" ||
169171
type.Name == "DateTime" ||
170172
type.Name == "ID"));
171173
}

Octokit.GraphQL.Core/Core/Syntax/VariableDefinition.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,10 @@ public static string ToTypeName(Type type, bool isNullable)
2323
{
2424
name = "Int";
2525
}
26+
else if (type == typeof(long))
27+
{
28+
name = "Long";
29+
}
2630
else if (type == typeof(double))
2731
{
2832
name = "Float";

0 commit comments

Comments
 (0)