You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
openGraphql_lwttypeuser = {id : int;name : string}
let hardcoded_users: user list= [
{id =1; name ="alice"};
{id =1; name ="bob"};
]
let user =Graphql_lwt.Schema.(obj "user"~fields:[
field "id"~typ:(non_null int)
~args:Arg.[]
~resolve:(fun_info (user: user) -> user.id);
field "name"~typ:(non_null string)
~args:Arg.[]
~resolve:(fun_info (user: user) -> user.name);
])
let schema =Graphql_lwt.Schema.(schema [
field "users"~typ:(non_null (list (non_null user)))
~args:Arg.[arg "id"~typ:int]
~resolve:(fun_info()id ->
match id with|None -> hardcoded_users
|Someid' ->
matchList.find_opt (fun{id; _} -> id = id') hardcoded_users with|None -> []|Someuser -> [user]);
])
Produces the following error:
| let user =
^^^^
Error: The type of this expression,
('_weak1, user option) Graphql_lwt.Schema.typ,
contains the non-generalizable type variable(s): '_weak1.
(see manual section 6.1.2)
The solution is to make user and schema a function to solve the issue.
The text was updated successfully, but these errors were encountered:
Hi everyone,
I was working through the graphql examples and I found out that the type system is not able to resolve all the types given in the example (https://github.com/aantron/dream/tree/master/example/i-graphql), so it does not compile.
Produces the following error:
The solution is to make
user
andschema
a function to solve the issue.The text was updated successfully, but these errors were encountered: