Skip to content

Commit 8fcdc11

Browse files
Copilotxperiandri
andauthored
Allow Long scalar coercion from integer literals during AST input validation (#571)
Co-authored-by: xperiandri <2365592+xperiandri@users.noreply.github.com> Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
1 parent a21befe commit 8fcdc11

2 files changed

Lines changed: 11 additions & 1 deletion

File tree

src/FSharp.Data.GraphQL.Shared/Validation.fs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -920,7 +920,7 @@ module Ast =
920920
| _ when tref.Kind = TypeKind.NON_NULL -> checkIsCoercible tref.OfType.Value argName value
921921
| IntValue _ ->
922922
match tref.Name, tref.Kind with
923-
| Some ("ID" | "Int" | "Float"), TypeKind.SCALAR -> Success
923+
| Some ("ID" | "Int" | "Long" | "Float"), TypeKind.SCALAR -> Success
924924
| _ -> canNotCoerce
925925
| FloatValue _ ->
926926
match tref.Name, tref.Kind with

tests/FSharp.Data.GraphQL.Tests/AstValidationTests.fs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,12 @@ let Arguments =
219219
[ Define.Input ("intArg", Nullable IntType) ],
220220
(fun ctx _ -> ctx.Arg ("intArg"))
221221
)
222+
Define.Field (
223+
"longArgField",
224+
Nullable LongType,
225+
[ Define.Input ("longArg", Nullable LongType) ],
226+
(fun ctx _ -> ctx.Arg ("longArg"))
227+
)
222228
Define.Field (
223229
"nonNullBooleanListField",
224230
ListOf BooleanType,
@@ -1020,6 +1026,10 @@ fragment coercedIntIntoFloatArg on Arguments {
10201026
floatArgField(floatArg: 123)
10211027
}
10221028
1029+
fragment coercedIntIntoLongArg on Arguments {
1030+
longArgField(longArg: 123)
1031+
}
1032+
10231033
query goodComplexDefaultValue($search: ComplexInput = { name: "Fido" }) {
10241034
findDog(complex: $search)
10251035
}"""

0 commit comments

Comments
 (0)