How to use the graphql-zeus.Parser.parse function in graphql-zeus

To help you get started, we’ve selected a few graphql-zeus 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 graphql-editor / graphql-editor / src / Graph / index.ts View on Github external
static getGraphqlWithoutRootSchema = (schema: string): string => {
    const basicDefinitions = Definitions.generate([]);
    const tree = TreeToNodes.resolveTree(Parser.parse(schema), basicDefinitions);
    const nodes = tree.nodes.map((n) => ({
      ...n,
      options: n.options.filter((no) => !(no in OperationType)),
    }));
    return NodesToTree.parse(nodes, tree.links);
  };
github graphql-editor / graphql-editor / src / Graph / index.ts View on Github external
loadLibraries = (schema?: string): void => {
    if (!schema) {
      return;
    }
    let basicDefinitions = Definitions.generate([]);
    this.stichesCode = schema;
    this.stitchNodes = TreeToNodes.resolveTree(Parser.parse(this.stichesCode), basicDefinitions);
    basicDefinitions = Definitions.generate(this.stitchNodes.nodes);
    const rememberBasicDefinitions = [...basicDefinitions];
    this.stitchNodes = TreeToNodes.resolveTree(Parser.parse(this.stichesCode), basicDefinitions);
    this.stitchDefinitions = basicDefinitions.filter((bd) => !rememberBasicDefinitions.find((rbd) => rbd.id === bd.id));
  };
  screenShot = async () => this.diagram!.screenShot();
github graphql-editor / graphql-editor / src / Graph / index.ts View on Github external
loadGraphQL = (schema: string, forceZero?: boolean) => {
    const zeroGraph = this.schema.length === 0 && !!schema;
    this.definitions = Definitions.generate(this.stitchNodes.nodes).concat(this.stitchDefinitions!);
    this.diagram!.setDefinitions(this.definitions);
    if (schema.length === 0) {
      this.resetGraph();
      return;
    }
    const result = TreeToNodes.resolveTree(
      Parser.parse(
        schema + this.stichesCode,
        this.stitchNodes.nodes.filter((n) => n.definition.root).map((n) => n.name),
      ),
      this.definitions,
    );
    this.diagram!.setDefinitions(this.definitions);
    this.load(result.nodes, result.links);
    if (zeroGraph || forceZero) {
      this.zeroGraph();
    }
  };
  centerOnNodeByID = (id: string) => {