graphql_ppx
graphql_ppx copied to clipboard
Return wrapped response for ReasonApollo
Nice to have:
The ppx could return a wrapped ReasonApollo module, based on bs-config, to make the usage easier from reason-apollo:
module AddUser = [%graphql {| ... |} ];
//This could be avoided if the ppx would do this
module AddUserMutation = ReasonApollo.CreateMutation(AddUser);
...
<AddUserMutation>
...{(mutation) => <button onClick={() => {
// This is not obvious, this would also be fixed by providing a tighter coupling
let addNewUserQuery = AddUser.make(~name="Bob", ());
// ^^^^^^^^ should I use AddUser or AddUserMutation
mutation(~variables=addNewUserQuery##variables,())
}}> mutate</button>}
</AddUserMutation>
I think it would make graphql_ppx coupled a lot with reason-apollo.
Another solution would be to provide the type of make
function making it possible to alias that function in reason-apollo
. That way AddUser
would be only used to provide it to CreateMutation
/CreateQuery
/CreateSubscription
and creating variables would be the responsibility of AddUserMutation
which would be much cleaner for the users