How to use babel-relay-plugin - 10 common examples

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
quasis.forEach((chunk, ii) => {
    chunks.push(chunk);

    if (ii !== quasis.length - 1) {
      const name = 'RQL_' + ii;
      const value = expressions[ii];

      runtime.fragments[name] = value;

      substitutions.push({name, value});

      if (/:\s*$/.test(chunk)) {
        invariant(
          false, // this.options.substituteVariables,
          'You supplied a GraphQL document named `%s` that uses template ' +
          'substitution for an argument value, but variable substitution ' +
          'has not been enabled.',
          documentName
        );
        chunks.push('$' + name);
        variableNames[name] = undefined;
      } else {
        chunks.push('...' + name);
      }
    }
  });
github facebook / relay / website-prototyping-tools / RelayPlayground.js View on Github external
graphql(Schema, introspectionQuery).then((result) => {
      if (
        this.state.schemaSource !== schemaSource ||
        this.state.appSource !== appSource
      ) {
        // This version of the code is stale. Bail out.
        return;
      }
      this._babelRelayPlugin = getBabelRelayPlugin(result.data);
      Relay.injectNetworkLayer(
        new RelayLocalSchema.NetworkLayer({
          schema: Schema,
          onError: (errors, request) => {
            this.setState({
              error: errorFromGraphQLResultAndQuery(errors, request),
              errorType: ERROR_TYPES.query,
            });
          },
        })
      );
      this._updateApp(appSource);
    });
  }
github prisma-archive / babel-plugin-react-relay / src / index.js View on Github external
})

  // TODO find a cleaner way to do this
  loopWhile(() => wait)

  // this error could happen while downloading the schema
  if (error) {
    throw error
  }

  if (schema.errors) {
    throw new Error(JSON.stringify(schema.errors))
  }

  if (schema.data) {
    return getBabelRelayPlugin(schema.data)(babel)
  } else {
    return {
      visitor: {}
    }
  }
}
github stubailo / relay-runtime-query / lib / index.js View on Github external
});
exports.initTemplateStringTransformer = initTemplateStringTransformer;

var _babelRelayPluginLibRelayQLTransformer = require('babel-relay-plugin/lib/RelayQLTransformer');

var _babelRelayPluginLibRelayQLTransformer2 = _interopRequireDefault(_babelRelayPluginLibRelayQLTransformer);

var _babelRelayPluginLibInvariant = require('babel-relay-plugin/lib/invariant');

var _babelRelayPluginLibInvariant2 = _interopRequireDefault(_babelRelayPluginLibInvariant);

var _graphqlUtilitiesIntrospectionQuery = require('graphql/utilities/introspectionQuery');

var _require = require('babel-relay-plugin/lib/GraphQL');

var buildClientSchema = _require.utilities_buildClientSchema.buildClientSchema;

function getSchema(schemaProvider) {
  var introspection = typeof schemaProvider === 'function' ? schemaProvider() : schemaProvider;
  (0, _babelRelayPluginLibInvariant2['default'])(typeof introspection === 'object' && introspection && typeof introspection.__schema === 'object' && introspection.__schema, 'Invalid introspection data supplied to `getBabelRelayPlugin()`. The ' + 'resulting schema is not an object with a `__schema` property.');
  return buildClientSchema(introspection);
}

function transform(schema, query) {
  var transformer = new _babelRelayPluginLibRelayQLTransformer2['default'](schema, {});
  var processed = transformer.processDocumentText(query, 'queryName');
  return processed;
}

// export function initTemplateStringTransformerFromUrl(url, callback) {
//   $.get(url, {
//     query: introspectionQuery
github grahammendick / navigation / NavigationReact / sample / relay / babelRelayPlugin.js View on Github external
import getbabelRelayPlugin from 'babel-relay-plugin';
import schema from './schema.json';

module.exports = getbabelRelayPlugin(schema.data);
github guymers / babel-plugin-flow-relay-query / src / index.js View on Github external
function createPlugin(
  schemaProvider: GraphQLSchemaProvider,
  babelpluginOptions: Object = {},
  pluginOptions: Object = {}
): Function {
  const babelRelayPlugin = getBabelRelayPlugin(schemaProvider, babelpluginOptions);

  const schema = createSchema(schemaProvider);
  const flowRelayQueryPlugin = createFlowRelayQueryPlugin(schema, pluginOptions);

  return function plugin(babel) {
    return {
      inherits: babelRelayPlugin(babel),
      ...flowRelayQueryPlugin(babel)
    };
  };
}
github MattMcFarland / reactathon / scripts / babelRelayPlugin.js View on Github external
import getBabelRelayPlugin from 'babel-relay-plugin';

import schema from '../data/schema.json';

var plugin = getBabelRelayPlugin(schema);

return babel.transform(source)


export default getBabelRelayPlugin(schema.data);
github cdebotton / react-relay-redux / webpack / helpers / babelRelayTransformer.js View on Github external
import getBabelRelayPlugin from 'babel-relay-plugin';

let data;

try {
  ({data} = require('../../build/schema.json'));
} catch (ex) {
  data = {};
}

export default getBabelRelayPlugin(data);
github MattMcFarland / reactathon / scripts / babelRelayPlugin.js View on Github external
import getBabelRelayPlugin from 'babel-relay-plugin';

import schema from '../data/schema.json';

var plugin = getBabelRelayPlugin(schema);

return babel.transform(source)


export default getBabelRelayPlugin(schema.data);

babel-relay-plugin

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

MIT
Latest version published 7 years ago

Package Health Score

62 / 100
Full package analysis

Similar packages