How to use the babel-relay-plugin/lib/GraphQL.utilities_buildClientSchema 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 / 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

babel-relay-plugin

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

MIT
Latest version published 8 years ago

Package Health Score

65 / 100
Full package analysis

Similar packages