New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details
Socket
Book a DemoSign in
Socket

@polywrap/schema-parse

Package Overview
Dependencies
Maintainers
2
Versions
59
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@polywrap/schema-parse

Polywrap Schema Parsing

Source
npmnpm
Version
0.11.2
Version published
Weekly downloads
274
63.1%
Maintainers
2
Weekly downloads
 
Created
Source

@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" })
  ]
});

FAQs

Package last updated on 21 Aug 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts