How to use the graphql-tag/loader.bind function in graphql-tag

To help you get started, we’ve selected a few graphql-tag 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 bamlab / react-native-graphql-transformer / index.js View on Github external
upstreamTransformer = require('metro/src/transformer');
} else if (reactNativeMinorVersion >= 0.47) {
  upstreamTransformer = require('metro-bundler/src/transformer');
} else if (reactNativeMinorVersion === 0.46) {
  upstreamTransformer = require('metro-bundler/build/transformer');
} else {
  // handle RN <= 0.45
  const oldUpstreamTransformer = require('react-native/packager/transformer');
  upstreamTransformer = {
    transform({ src, filename, options }) {
      return oldUpstreamTransformer.transform(src, filename, options);
    },
  };
}

const gqlTransform = gqlLoader.bind({
  cacheable: () => null,
});

function transform(src, filename, options) {
  if (typeof src === 'object') {
    // handle RN >= 0.46
    ({ src, filename, options } = src);
  }

  // Do custom transformations
  let result = src;
  if (filename.endsWith('.gql') || filename.endsWith('.graphql')) {
    result = gqlTransform(result);
  }

  const babelCompileResult = upstreamTransformer.transform({

graphql-tag

A JavaScript template literal tag that parses GraphQL queries

MIT
Latest version published 3 years ago

Package Health Score

83 / 100
Full package analysis

Similar packages