How to use the reason.printRE 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 / 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,
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 prisma-labs / graphqlgen / packages / graphqlgen / src / generators / reason / generator.ts View on Github external
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
  }
}
github kgoggin / reason-react-apollo / src / index.ts View on Github external
const refmt = (str: string) => printRE(parseRE(str));
github OneGraph / graphiql-code-exporter / src / snippets / reason / apollo.js View on Github external
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}>
      ...{

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