How to use the relay-compiler.Schema.DEPRECATED__create function in relay-compiler

To help you get started, weโ€™ve selected a few relay-compiler 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 facebook / relay / packages / relay-test-utils-internal / TestCompiler.js View on Github external
function generate(
  text: string,
  schema: GraphQLSchema,
  transforms: RelayCompilerTransforms,
  moduleMap: ?{[string]: mixed},
): {[key: string]: GeneratedNode} {
  const relaySchema = transformASTSchema(schema, IRTransforms.schemaExtensions);
  const {definitions, schema: extendedSchema} = parseGraphQLText(
    relaySchema,
    text,
  );
  const compilerContext = new GraphQLCompilerContext(
    Schema.DEPRECATED__create(schema, extendedSchema),
  ).addAll(definitions);
  const documentMap = {};
  compileRelayArtifacts(compilerContext, transforms).forEach(
    ([_definition, node]) => {
      const transformedNode =
        moduleMap != null ? CodeMarker.transform(node, moduleMap) : node;
      documentMap[
        node.kind === 'Request' ? node.params.name : node.name
      ] = transformedNode;
    },
  );
  return documentMap;
}
github facebook / relay / packages / relay-test-utils-internal / parseGraphQLText.js View on Github external
function parseGraphQLText(
  schema: GraphQLSchema,
  text: string,
): {
  definitions: $ReadOnlyArray,
  schema: GraphQLSchema,
} {
  const ast = parse(text);
  const extendedSchema = extendSchema(schema, ast, {assumeValid: true});
  const definitions = convertASTDocuments(
    Schema.DEPRECATED__create(schema, extendedSchema),
    [ast],
    Parser.transform.bind(Parser),
  );
  return {
    definitions,
    schema: extendedSchema,
  };
}