How to use the reason.parseRE function in reason

To help you get started, we’ve selected a few reason examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github OneGraph / graphiql-code-exporter / src / snippets / reasonFetch.js View on Github external
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 ++ "."
      };`),
    );
  },
};
github OneGraph / graphiql-code-exporter / src / snippets / reason / fetch.js View on Github external
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))),
github rebench / rebench.github.io / lib / js / src / common / ffi / Refmt.js View on Github external
return _wrap((function (prim) {
                return Reason.parseRE(prim);
              }), param);
}
github OneGraph / graphiql-code-exporter / src / snippets / reason / apollo.js View on Github external
? `
  
    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}) =>

reason

Simple, fast & type safe code that leverages the JavaScript & OCaml ecosystems

MIT
Latest version published 6 years ago

Package Health Score

72 / 100
Full package analysis