Compile-time error: "Argument field or value named 'order_by' can not be coerced"
See original GitHub issueDescription
I am using Hasura, and trying to run the following query:
let operation = MyProvider.Operation<"""query q {
test_table (order_by: {some_name: asc}) {
id
some_name
}
}""">
The query is valid and works if run manually, but I get a compile-time error with the F# Type Provider:
error FS3033: The type provider 'FSharp.Data.GraphQL.Client.GraphQLTypeProvider'
reported an error:
Argument field or value named 'order_by' can not be coerced.
It does not match a valid literal representation for the type.
Path: ["q"; "test_table"]
The relevant part of the schema:
{
"inputFields": null,
"kind": "ENUM",
"possibleTypes": null,
"interfaces": null,
"name": "order_by",
"enumValues": [
{
"isDeprecated": false,
"deprecationReason": null,
"name": "asc",
"description": "in the ascending order, nulls last"
},
...
],
"description": "column ordering options",
"fields": null
}
I’ve tried other parameters, such as offset
, limit
, where
(this one works now: https://github.com/fsprojects/FSharp.Data.GraphQL/issues/263), and they work. distinct_on
, however, results in the same compile time error. Could this have something to do with the _
in the name?
Repro steps
See description.
Expected behavior
The application compiles, the query returns the same result as when run manually.
Actual behavior
Compile-time error.
Known workarounds
None.
Related information
- Mac OS X
- Version 1.0.3
- .NET Core 3.1
Issue Analytics
- State:
- Created 3 years ago
- Comments:6 (2 by maintainers)
Top Results From Across the Web
Ordering by specific field value first - mysql
SELECT id, name, priority FROM mytable ORDER BY FIELD(name, "core", ... If the value of the field is not in the list, it...
Read more >GraphQL specification
A GraphQL server, when preparing a field of a given scalar type, must uphold the contract the scalar type describes, either by coercing...
Read more >Conversion rules | BigQuery
Literal conversion is evaluated at analysis time, and gives an error if the input literal cannot be converted successfully to the target type....
Read more >Troubleshooting F# | F# for fun and profit
As the saying goes, “if it compiles, it's correct”, but it can be extremely frustrating just trying to get the code to compile...
Read more >Runtime and compile-time metaprogramming
Exactly one constructor will be produced. Attempting to use an initial value will produce an error. Map-style named arguments won't be available.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I had the exact same problem, a workaround is to wrap the order_by value in a list (credits to @Yakimych):
Does not work:
order_by: {some_name: asc}
Works:order_by: [{some_name: asc}]
This appears to be a bug in how FSharp.Data.GraphQL does input coercion:
@johnberzy-bazinga Got the same problem when trying to create a mutation against the same schema:
The mutation itself: