How to use the babel-relay-plugin/lib/generateHash function in babel-relay-plugin

To help you get started, we’ve selected a few babel-relay-plugin 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 stubailo / relay-runtime-query / src / index.js View on Github external
function templateStringTag(quasis, ...expressions) {
    const processedTemplateLiteral = processTemplateLiteral(quasis, expressions, 'queryName');

    const processedTemplateText = transformer.processTemplateText(processedTemplateLiteral.templateText, {
      documentName: 'queryName',
      propName: 'propName'
    });

    const definition = transformer.processDocumentText(processedTemplateText, {
      documentName: 'queryName',
      propName: 'propName',
      fragmentLocationID: generateHash(JSON.stringify(processedTemplateText)).substring(0, 12)
    });

    const options = {};
    const Printer = RelayQLPrinter(t, options);

    modifyPrinterClass(Printer);

    const printed = new Printer('wtf??', {})
      .print(definition, []);

    return printed;
  }

babel-relay-plugin

Babel Relay Plugin for transpiling GraphQL queries for use with Relay.

MIT
Latest version published 8 years ago

Package Health Score

62 / 100
Full package analysis

Similar packages