Skip to content

Allow string inputs for Long Scalar type#1163

Merged
yanns merged 3 commits intosangria-graphql:mainfrom
jakobmerrild:coerce-incoming-strings-for-long-type
Dec 16, 2024
Merged

Allow string inputs for Long Scalar type#1163
yanns merged 3 commits intosangria-graphql:mainfrom
jakobmerrild:coerce-incoming-strings-for-long-type

Conversation

@jakobmerrild
Copy link
Contributor

Solves: #1162

Let me know if this is really something that should be solved in sangria-circe instead?

@yanns
Copy link
Contributor

yanns commented Dec 14, 2024

There's a compilation error with scala 2.12:

 [error] /home/runner/work/sangria/sangria/modules/core/src/main/scala/sangria/schema/package.scala:50:27: value toLongOption is not a member of String
[error] Error occurred in an application involving default arguments.
[error]       case s: String if s.toLongOption.isDefined => Right(s.toLong)
[error]                           ^
[error] /home/runner/work/sangria/sangria/modules/core/src/main/scala/sangria/schema/package.scala:57:48: value toLongOption is not a member of String
[error] Error occurred in an application involving default arguments.
[error]       case ast.StringValue(s, _, _, _, _) if s.toLongOption.isDefined => Right(s.toLong)
[error]                                                ^

The `.toLongOption` function isn't available in Scala 2.12
@jakobmerrild
Copy link
Contributor Author

I tried to create a specification for a custom Long scalar: graphql/graphql-scalars#26

@yanns yanns added this pull request to the merge queue Dec 16, 2024
Merged via the queue into sangria-graphql:main with commit e86440f Dec 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants