Title: Issue · GitHub
Open Graph Title: Issue · graphql-java/graphql-java
X Title: Issue · graphql-java/graphql-java
Description: GraphQL Java implementation. Contribute to graphql-java/graphql-java development by creating an account on GitHub.
Open Graph Description: GraphQL Java implementation. Contribute to graphql-java/graphql-java development by creating an account on GitHub.
X Description: GraphQL Java implementation. Contribute to graphql-java/graphql-java development by creating an account on GitHub.
Opengraph URL: https://github.com/graphql-java/graphql-java
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"regression in GraphQLScalarType Coercing parseValue in 18.1","articleBody":"**Describe the bug**\r\n\r\nI just hit a bug in production when deploying an upgrade from 18.0 to 18.1 that I think relates to some of the work in resolving https://github.com/graphql-java/graphql-java/issues/2811\r\n\r\nI noticed the following in my production logs \r\n\r\n```\r\n...\r\nCaused by: graphql.schema.CoercingParseValueException: Variable 'memberDues' has an invalid value: Failed to parse input value 2022-05-16T19:52:37Z as ZonedDateTime\r\n...\r\n\r\nCaused by: java.lang.IllegalArgumentException: Unexpected input type: class java.time.ZonedDateTimeat com.meetup.graphql.wiring.CustomScalars.parseDateTimeValue(CustomScalars.java:38)at com.meetup.graphql.wiring.CustomScalars$1.parseValue(CustomScalars.java:71)at com.meetup.graphql.wiring.CustomScalars$1.parseValue(CustomScalars.java:63)at graphql.execution.ValuesResolver.externalValueToInternalValueForScalar(ValuesResolver.java:578)at graphql.execution.ValuesResolver.externalValueToInternalValue(ValuesResolver.java:510)at graphql.execution.ValuesResolver.externalValueToInternalValue(ValuesResolver.java:498)at graphql.execution.ValuesResolver.externalValueToInternalValueForObject(ValuesResolver.java:565)at graphql.execution.ValuesResolver.externalValueToInternalValue(ValuesResolver.java:517)at graphql.execution.ValuesResolver.externalValueToInternalValueForObject(ValuesResolver.java:565)at graphql.execution.ValuesResolver.externalValueToInternalValue(ValuesResolver.java:517)at graphql.execution.ValuesResolver.externalValueToInternalValue(ValuesResolver.java:498)at graphql.execution.ValuesResolver.externalValueToInternalValueForVariables(ValuesResolver.java:410)\r\n```\r\n\r\nnote that the string `2022-05-16T19:52:37Z` is actually parsable as ZonedDateTime however I believe the issue is previously `parseValue` was receiving either a String or a StringValue and after this upgrade it started receiving the value that I was attempting to coerce it into, in this case a ZonedDateTime\r\n\r\nis this new expected behavior or was this previous expected behavior that was underspecified until now?\r\n\r\nHere's an abbreviated version of a custom scaler for parsing out ZonedDateTime values which is roughly based on the [docs](https://www.graphql-java.com/documentation/scalars/#example-implementation)\r\n\r\n```java\r\n static ZonedDateTime parseDateTimeValue(Object input) {\r\n try {\r\n if (input instanceof StringValue) {\r\n return ZonedDateTime.parse(((StringValue) input).getValue());\r\n } else if (input instanceof String) {\r\n return ZonedDateTime.parse((String) input);\r\n } else throw new IllegalArgumentException(\"Unexpected input type: \" + input.getClass()); \u003c-- change in behavior causes this line to get evaluated\r\n } catch (Exception e) {\r\n throw new CoercingParseValueException(\r\n \"Failed to parse input value \" + input + \" as ZonedDateTime\", e);\r\n }\r\n }\r\n \r\npublic static final GraphQLScalarType DateTime =\r\n GraphQLScalarType.newScalar()\r\n .name(\"DateTime\")\r\n .description(\"A custom scalar that handles timestamps\")\r\n .coercing(\r\n new Coercing\u003cZonedDateTime, String\u003e() {\r\n @Override\r\n public String serialize(Object dataFetcherResult) {\r\n return // doesnt matter\r\n }\r\n\r\n @Override\r\n public ZonedDateTime parseValue(Object input) {\r\n return parseDateTimeValue(input);\r\n }\r\n\r\n @Override\r\n public ZonedDateTime parseLiteral(Object input) {\r\n return // doesnt matter\r\n }\r\n })\r\n .build();\r\n```\r\n\r\n**To Reproduce**\r\nPlease provide a code example or even better a test to reproduce the bug.\r\n\r\nsee above\r\n","author":{"url":"https://github.com/softprops","@type":"Person","name":"softprops"},"datePublished":"2022-05-16T20:35:13.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":7},"url":"https://github.com/2819/graphql-java/issues/2819"}
| route-pattern | /:user_id/:repository/issues/:id(.:format) |
| route-controller | issues |
| route-action | show |
| fetch-nonce | v2:63c64875-7303-49f0-41b3-2cf22c05057a |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | A474:3734F2:18D431:21B1A6:6A5FEA74 |
| html-safe-nonce | b5426deb7d9280e2e0e3457e2254c69a1e19a7d92e3fdbe390746b1bb94deb70 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBNDc0OjM3MzRGMjoxOEQ0MzE6MjFCMUE2OjZBNUZFQTc0IiwidmlzaXRvcl9pZCI6IjgyNzkwNzgzMDQxNDc4MjczMTYiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | f03fbd141123784b0dc5dc8381b0ec9154b987096e81a9e8fbf0933114a80dda |
| hovercard-subject-tag | repository:38602457 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/graphql-java/graphql-java/issues/2819 |
| twitter:image | https://opengraph.githubassets.com/bc7bc6e813395e81ad82c20f716a6534dff9c2fc97964b6ef168bd75b4d8e140/graphql-java/graphql-java |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/bc7bc6e813395e81ad82c20f716a6534dff9c2fc97964b6ef168bd75b4d8e140/graphql-java/graphql-java |
| og:image:alt | GraphQL Java implementation. Contribute to graphql-java/graphql-java development by creating an account on GitHub. |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| hostname | github.com |
| expected-hostname | github.com |
| None | ba296ecd3a3521238fe43b3b3b08cc09207ddc21173e16ee656db03803de8e2b |
| turbo-cache-control | no-cache |
| go-import | github.com/graphql-java/graphql-java git https://github.com/graphql-java/graphql-java.git |
| octolytics-dimension-user_id | 14289921 |
| octolytics-dimension-user_login | graphql-java |
| octolytics-dimension-repository_id | 38602457 |
| octolytics-dimension-repository_nwo | graphql-java/graphql-java |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 38602457 |
| octolytics-dimension-repository_network_root_nwo | graphql-java/graphql-java |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 6e50fb37e29e4aa0df6386cb485e58b0e3ca97ab |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width