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))),
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,
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 ++ "."
};`),
);
},
};
export function format(code: string) {
try {
return refmt.printRE(refmt.parseRE(code))
} catch (e) {
console.log(
`There is a syntax error in generated code, unformatted code printed, error: ${JSON.stringify(
e,
)}`,
)
return code
}
}
export const refmt = (str: string) => printRE(parseRE(str));
return _wrap((function (prim) {
return Reason.parseRE(prim);
}), param);
}
const refmt = (str: string) => printRE(parseRE(str));
? `
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}) =>
const apolloClient = options.client
? `
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}>
...{