How to use the relay-compiler.createUserError 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 relay-tools / relay-compiler-language-typescript / src / TypeScriptGenerator.ts View on Github external
selection.schemaName === EDGES
      )
    );
  });

  const edgesItem = Array.isArray(edgesSelection) ? edgesSelection[0] : null;

  const nodeSelections =
    edgesItem != null &&
    typeof edgesItem === "object" &&
    edgesItem.nodeSelections instanceof Map
      ? edgesItem.nodeSelections
      : null;

  if (nodeSelections == null) {
    throw createUserError(
      "Cannot generate flow types for connection field, expected an edges " +
        "selection.",
      [node.loc]
    );
  }

  const edgesFields = Array.from(nodeSelections.values()) as any[];

  const edgesType = selectionsToAST(schema, [edgesFields], state, false);

  return [
    {
      key: "__connection",
      conditional: true,
      value: ts.createTypeReferenceNode("ConnectionReference", [edgesType])
    }