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

faunadb-graphql-schema-loader

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

faunadb-graphql-schema-loader

Package to simplify uploading GraphQL Schema to FaunaDB

  • 0.0.1
  • unpublished
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
0
Maintainers
1
Weekly downloads
 
Created
Source

FaunaDB GraphQL Schema Loader

A lib with some helper functions to make uploading a schema to FaunaDB easier.

Basic Usage

const { importSchema } = require('faunadb-graphql-schema-loader')

const secret = process.env.FAUNADB_ADMIN_KEY

const schema = `
  type Budget {
    name: String!
    owner: User! @relation
  }
  type User {
    budget: Budget! @relation
    name: String!
  }
  `

importSchema(secret, schema).then((res) => console.log(res))

API

importSchema

importSchema = (faunadbKey: string, schema: string) => Promise<string>

Takes a schema string and uploads that to the database with the provided Admin Key.

Parameters

  • faunadbKey An Admin key for your database
  • schema An SDL schema string

Returns a Promise for the response.body from the http request.

See basic example

makeSchema

makeSchema = (typeDefs: string[]) => string

Takes a list of SDL schema strings and combines them. This allows for using extends in your type definitions.

Parameters

  • typeDefs Array of SDL schema strings

Returns A single SDL schema string.

See extended types example

getTypeDefsFromFiles

getTypeDefsFromFiles = (paths: string[]) => string[]

Takes a list of relative file paths (from current working directory) and synchronously reads them.

Parameters

  • paths Array of relative file paths.

Returns An array of strings containing contents of the files indicated. Hopefully SDL schemas!

See modules example

Using and Contributing

This package is quite small, and a bit opinionated on how to read in SDL files. Rather than add this as a project dependancy, I would actually recommend (at this point) just copying the source or the basics of it to your own code.

However, any feedback is appreciated, and if folks see ways to make this into a useful and viable package, I will work to make it so! Please fill out a Github Issue if you see anything.

Thanks!

License

The MIT License (MIT)

FAQs

Package last updated on 14 Jul 2020

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