Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

appsync-schema-converter

Package Overview
Dependencies
Maintainers
1
Versions
23
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

appsync-schema-converter

Converts modern schemas into AppSync compatible version.

  • 0.1.2
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
253
increased by58.13%
Maintainers
1
Weekly downloads
 
Created
Source

AppSync Schema Converter

The sole purpose of this package is to convert modern GraphQL schemas into AppSync compatible version.

  1. printSchema() is a copy of graphql@^14.4.2/utilities/schemaPrinter.js@printSchema with includesDirectives: Boolean option added.
  2. convertSchemas(schemas: [string]) takes an array of GraphQL SDL string and converts them into one single AppSync comptaible schema.

My team only works with Apollo, so expects more care on that front.

If AppSync updates their ancient GraphQL engine, I am more than happy to ditch this package.

Serverless Framework

This package also made with serverless-appsync-plugin in mind, especially useful when merge-graphql-schemas was in your stack.

You make use of variables in JavaScript and write a little script to merge schemas into AppSync compatible one.

Based on your serverless-appsync-plugin settings, change this line in your serverless.yml.

custom:
  appSync:
    schema: ${file(schema.js):compile}

Then read and convert your schemas in schema.js@compile.

const { promisify } = require('util');
const glob = require('glob');
const { readFile, writeFile } = require('fs').promises;
const { convertSchemas } = require("appsync-schema-converter");

const SCHEMA_PATH = './schema.graphql';

module.exports.compile = async _ => {
  let schemas;

  schemas = await promisify(glob)(`${__dirname}/schemas/**/*.graphql`);
  schemas = await Promise.all(schemas.map(async schema => (await readFile(schema)).toString('utf8')));

  schemas = convertSchemas(schemas, {
    commentDescriptions: true,
    includeDirectives: true,
  });

  await writeFile(SCHEMA_PATH, schemas);

  return SCHEMA_PATH;
};

Contributors

Keywords

FAQs

Package last updated on 06 Nov 2019

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc