Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
generate: ({
appId,
variableName,
operationType,
operationName,
operation,
options,
}) => {
// snippet here
return refmt.printRE(
refmt.parseRE(`type schoolPerson = Teacher | Director | Student(string);
let greeting = person =>
switch (person) {
| Teacher => "Hey Professor!"
| Director => "Hello Director."
| Student("Richard") => "Still here Ricky?"
| Student(anyOtherName) => "Hey, " ++ anyOtherName ++ "."
};`),
);
},
};
generate: ({
serverUrl,
variableName,
operationType,
operationName,
operation,
options,
}) => {
// snippet here
return refmt.printRE(
refmt.parseRE(`
let serverUrl = "${serverUrl}"
let ${variableName} = [%graphql
{|
${operation}
|}
]
let payload = Js.Dict.empty();
Js.Dict.set(payload, "${operationType}", Js.Json.string(${variableName}));
Js.Promise.(
Fetch.fetch(serverUrl,
Fetch.RequestInit.make(
~method_=Post,
~body=Fetch.BodyInit.make(Js.Json.stringify(Js.Json.object_(payload))),
return _wrap((function (prim) {
return Reason.parseRE(prim);
}), param);
}
? `
let inMemoryCache = ApolloInMemoryCache.createInMemoryCache();
let serverUrl = "${serverUrl}"
let httpLink =
ApolloLinks.createHttpLink(~uri=serverUrl, ());
let instance =
ReasonApollo.createApolloClient(~link=httpLink, ~cache=inMemoryCache, ());
`
: '';
return refmt.printRE(
refmt.parseRE(`
${apolloClient}
module ${queryName} = [%graphql
{|
${operation}
|}
];
module ${componentName} = ReasonApollo.CreateQuery(${queryName});
let make = _children => {
render: _ => {
${options.client ? '' : ''}
<${componentName}>
...{
({result}) =>