-
Notifications
You must be signed in to change notification settings - Fork 6
Deriving query code from type #66
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
@CGenie I can see the use of this but unfortunately this library does not support this yet. This could probably be achieved outside of this library by defining your own type class that would deep map a record proxy (in this case i.e. class GetQueryFields r query | r -> query where
getQueryFields :: Proxy (Record r) -> query
The the instances could be defined using The only part I'm not sure of is how to handle arguments on fields. Do you know how Morpheus handles this?
I'll have a look at adding this today |
@CGenie I've added some functions that generate queries from types at https://github.com/OxfordAbstracts/purescript-graphql-client/pull/68/files . Is this the sort of thing you had in mind? |
For Morpheus you basically need to derive the Thanks @roryc89 for that solution, looks interesting, I'll check out in more detail and will let you know. |
Is it possible to do a similar thing for Then my question is https://github.com/OxfordAbstracts/purescript-graphql-client/pull/68/files#diff-404493334c4108c2411bd1767059be2e94295df5742d14d58116667dc5e80dd7R16-R19 really necessary, seems like duplication of the |
No that's not necessary. It was just a type level test so I could check that For custom types, you could either derive the type class instance using |
I think that keeping the ability to run the queries without a type is also useful as sometimes I want to query a graphql api without having to write out the return type but still have it inferred |
At the moment we generate the purescript sum type from graphql enums during codegen. You can see an example of this at https://github.com/OxfordAbstracts/purescript-graphql-client/blob/main/examples/3-enums/src/Main.purs |
Hello,
Suppose I have a type
Is it possible to automatically create a "full" query for it? I.e I don't want to type
and then create a schema out of it, and then remap the
UserGQL
from the response but just directly defineUser
in schema and have it automatically generate all fields for the query?Just a note: my model is more complex, with complex types inside of it. On the Haskell side I'm able to derive the deeply nested models structure via the
Morpheus
library without hand-writing anything.The text was updated successfully, but these errors were encountered: