Closed MargaretKrutikova closed 4 years ago
Hi @MargaretKrutikova, I believe custom scalars compile to strings if they are not recognized. Can you please elaborate more on your issue? Are the types not being generated at all or the is the generated code not compiling at all?
Yes, I should have been more specific. Types of query and mutation parameters don't get compiled to string. If custom scalar types are used in the response, they are indeed compiled to strings.
I see, so parameter types are not mapped to strings. Do you happen to have a sample schema and sample query/mutation that I can debug against? If the types are date and timestamptz and they are transferred as ISO-8601 dates then we should be able to map those to DateTime for date and DateTimeOffset for timestamptz
Yes, here is the schema, and a query you can test against:
query GetCurrentOrderQuery($userId: Int!, $deliveryDate: timestamptz!) {
userOrders(
where: { userId: { _eq: $userId }, deliveryDate: { _gte: $deliveryDate } }
) {
status
id
deliveryDate
userOrderDetails {
amount
id
price
status
}
}
}
Awesome, thanks a lot! This is enough information for me start debugging the issue. I will work on it soon and will keep you posted :smile:
Closed the issue by accident, nvm that
Great, thanks a lot! 🙂
Hi @MargaretKrutikova, I just published a new version of Snowflaqe and your issue should now be resolved as of v1.5 :rocket:
I was able to reproduce the problem where a custom scalar type like timestamptz
was being as is in the generated code for the input variables which of course breaks the whole project because such type is not recognized in F#. I fixes this problem by:
string
in input variables as well as resolved fieldstimestamptz
and converting that to an idiomatic DateTimeOffset
type in F# You should be able to update the tool by first uninstalling it and then re-installing:
dotnet tool uninstall snowflaqe -g
dotnet tool install snowflaqe -g
Please let me know if this actually solves the problem at hand 🙏 reopen the issue if the problem persists (or if you encounter any more of these types of issues)
Just verified that everything works properly with the new version. Thanks a lot for your hard work! 🙂
Are these types specific to PostgreSQL? I tried to search them and only GraphQL with PostgreSQL articles appear.
@xperiandri these types are specific to hasura, snowflaqe knows about them and translates them accordingly
Hi,
On a related note to this:
I had a go at generating a client for a GraphQl service written using Hot Chocolate and I notice that properties defined on the server as C# long
are represented in the generated schema as a custom scalar type Long
(there is some documentation about that at https://chillicream.com/docs/hotchocolate/v10/schema/custom-scalar-types).
Those are currently represented as string
in the F# client generated by Snowflaqe.
I was just wondering if there are any thoughts or objections to the idea of recognizing those in the generator, and exposing the properties as int64
instead of string?
Must be a simple fix
@Numpsy I've fixed this issue in latest Snowflaqe v1.27 it should now handle Long
as int64
please give it a try and confirm whether it works for you or not.
I am using
hasura
graphql api and for dates it generates custom scalars likedate
andtimestamptz
, which get mapped to the same types in F#, but there are no such types in F# 🙂Is there any way to provide custom mapping for those scalar types to F# types? I would happy even with strings there, but for now nothing compiles 🙂
Thanks!