Skip to content

Commit

Permalink
First pass at adding long values to spec parsing
Browse files Browse the repository at this point in the history
  • Loading branch information
kfcampbell committed Feb 27, 2024
1 parent e257114 commit 43411a9
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 5 deletions.
9 changes: 9 additions & 0 deletions Octokit.GraphQL.Core.Generation/Models/TypeModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,15 @@ public static TypeModel Int()
};
}

public static TypeModel Long()
{
return new TypeModel
{
Kind = TypeKind.Scalar,
Name = "Long",
};
}

public static TypeModel ID()
{
return new TypeModel
Expand Down
12 changes: 7 additions & 5 deletions Octokit.GraphQL.Core.Generation/Utilities/TypeUtilities.cs
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ internal static object GetArgName(InputValueModel arg)

public static bool IsCSharpPrimitive(TypeModel type)
{
return type.Kind == TypeKind.Scalar ||
return type.Kind == TypeKind.Scalar ||
type.Kind == TypeKind.Enum ||
(type.Kind == TypeKind.NonNull && IsCSharpPrimitive(type.OfType));
}
Expand Down Expand Up @@ -113,7 +113,7 @@ public static TypeModel ReduceType(TypeModel type)

return type;
}

public static string GetGraphQlIdentifierAttribute(string graphQlModelType)
{
if (graphQlModelType == null)
Expand All @@ -133,6 +133,7 @@ private static string GetCSharpType(TypeModel type, bool nullableType, bool retu
switch (type.Name)
{
case "Int": return "int" + question;
case "Long": return "long" + question;
case "Float": return "double" + question;
case "String": return "string";
case "Boolean": return "bool" + question;
Expand Down Expand Up @@ -162,10 +163,11 @@ private static string GetCSharpType(TypeModel type, bool nullableType, bool retu
private static bool IsValueType(TypeModel type)
{
return type.Kind == TypeKind.Enum ||
(type.Kind == TypeKind.Scalar &&
(type.Kind == TypeKind.Scalar &&
(type.Name == "Int" ||
type.Name == "Float" ||
type.Name == "Boolean" ||
type.Name == "Long" ||
type.Name == "Float" ||
type.Name == "Boolean" ||
type.Name == "DateTime" ||
type.Name == "ID"));
}
Expand Down
4 changes: 4 additions & 0 deletions Octokit.GraphQL.Core/Core/Syntax/VariableDefinition.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@ public static string ToTypeName(Type type, bool isNullable)
{
name = "Int";
}
else if (type == typeof(long))
{
name = "Long";
}
else if (type == typeof(double))
{
name = "Float";
Expand Down

0 comments on commit 43411a9

Please sign in to comment.