This repository has been archived by the owner on Nov 20, 2020. It is now read-only.
Simplified usage
Biggest release in a while!
As now with teamwalnut/graphql-ppx#48 we could simplify the API.
Thanks for everyone involved in this, special thanks @jfrolich who first proposed the changes to happen.
How it was
module GetAllPersonsConfig = [%graphql
{|
query getAllPersons($skip: Int!, $first: Int!) {
allPersons(skip: $skip, first: $first) {
id
age
name
}
}
|}
];
module GetAllPersonsQuery = ReasonApolloHooks.Query.Make(GetAllPersonsConfig);
let personsPerPage = 10;
[@react.component]
let make = () => {
let skipRef = React.useRef(0);
let (simple, full) =
GetAllPersonsConfig.make(~skip=0, ~first=personsPerPage, ());
How it is now
module GetAllPersonsQuery = [%graphql
{|
query getAllPersons($skip: Int!, $first: Int!) {
allPersons(skip: $skip, first: $first) {
id
age
name
}
}
|}
];
let personsPerPage = 10;
[@react.component]
let make = () => {
let skipRef = React.useRef(0);
let (simple, full) =
ApolloHooks.useQuery(
~variables=
GetAllPersonsQuery.makeVariables(~skip=0, ~first=personsPerPage, ()),
~notifyOnNetworkStatusChange=true,
GetAllPersonsQuery.definition,
);
No more functors!
Additional thanks to: @MargaretKrutikova , @kamilkuz