0.12.2 • Published 6 months ago

@polywrap/schema-parse v0.12.2

Weekly downloads
-
License
MIT
Repository
github
Last release
6 months ago

@polywrap/schema-parse

Parse & validate WRAP schemas, converting them into a WRAP ABI structure. Optionally perform transformations upon the WRAP ABI.

Usage

import {
  Abi,
  parseSchema,
  ParserOptions
} from "@polywrap/schema-parse";

const schema = readFileSync("module.graphql", "utf-8");
const options: ParserOptions = { };

const abi: Abi = parseSchema(schema, options);

Options

interface ParserOptions {
  // Disable schema validation
  noValidate?: boolean;
  // Use custom validators
  validators?: SchemaValidatorBuilder[];
  // Use custom extractors
  extractors?: SchemaExtractorBuilder[];
  // Use custom transformations
  transforms?: AbiTransforms[];
}

ABI Transforms

ABI transformations can be used to modify the ABI structure. A variety of pre-defined transformations can be found in the ./src/transform/ directory.

Example:

import {
  Abi,
  AbiTransforms,
  GenericDefinition,
  parseSchema
} from "@polywrap/schema-parse";

function extendType(extension: any): AbiTransforms {
  return {
    enter: {
      Abi: (abi: Abi) => ({
        ...abi,
        extension,
      }),
      GenericDefinition: (def: GenericDefinition) => ({
        ...def,
        ...extension,
      }),
    },
  };
}

Usage:

parseSchema(schema, {
  transforms: [
    extendType({ newProp: "foo" })
  ]
});
0.11.0

9 months ago

0.11.1

9 months ago

0.11.2

9 months ago

0.11.3

8 months ago

0.11.4

8 months ago

0.12.0

8 months ago

0.12.1

7 months ago

0.11.0-pre.4

10 months ago

0.12.2

6 months ago

0.11.0-pre.2

10 months ago

0.11.0-pre.3

10 months ago

0.10.6

10 months ago

0.11.0-pre.0

10 months ago

0.11.0-pre.1

10 months ago

0.10.3

12 months ago

0.10.4

11 months ago

0.10.5

11 months ago

0.10.1

1 year ago

0.10.2

1 year ago

0.10.0-pre.14

1 year ago

0.10.0

1 year ago

0.9.7

1 year ago

0.10.0-pre.13

1 year ago

0.10.0-pre.12

1 year ago

0.10.0-pre.11

1 year ago

0.10.0-pre.10

1 year ago

0.9.6

1 year ago

0.9.5

1 year ago

0.10.0-pre.8

1 year ago

0.10.0-pre.7

1 year ago

0.10.0-pre.6

1 year ago

0.10.0-pre.3

1 year ago

0.10.0-pre.4

1 year ago

0.10.0-pre.1

1 year ago

0.10.0-pre.5

1 year ago

0.9.4

2 years ago

0.9.3

2 years ago

0.10.0-pre.0

2 years ago

0.9.0

2 years ago

0.9.2

2 years ago

0.9.1

2 years ago

0.8.0

2 years ago

0.5.0

2 years ago

0.4.1

2 years ago

0.7.0

2 years ago

0.6.0

2 years ago

0.4.0

2 years ago

0.3.0

2 years ago

0.2.0

2 years ago

0.1.1

2 years ago

0.1.0

2 years ago