@currentdesk/prismatize

A node library that converts your database into a GraphQL API like Prisma.

Stats

StarsIssuesVersionUpdatedCreatedSize
@currentdesk/prismatize
010.1.17-dev.453 years ago3 years agoMinified + gzip package size for @currentdesk/prismatize in KB

Readme

Prismatize

A node library that converts your database into a GraphQL API like Prisma.

CLI Usage

npx @currentdesk/prismatize expand ./input.graphql [./output.graphql]

Import Examples

MongoDb with Resolver Mapping

import {
  expandSchema,
  mapResolvers,
} from '@currentdesk/prismatize'

// Using `graphql-import-loader`
import types from './schema/index.graphql'

const typeDefs = expandSchema(types, 'mongo')
const resolvers = mapResolvers(typeDefs, {
  type: 'mongo',
  uri: '', // database connection uri
  database: '', // database name
})

Serverless Lambda with GraphQL-Yoga and MongoDb Resolver Mapping

import {
  APIGatewayEvent,
  Callback,
  Context,
  Handler
} from 'aws-lambda'
import { GraphQLServerLambda } from 'graphql-yoga'

import {
  expandSchema,
  mapResolvers,
} from '@currentdesk/prismatize'

// Using `graphql-import-loader`
import types from './schema/index.graphql'

const typeDefs = expandSchema(types, 'mongo')
const resolvers = mapResolvers(typeDefs, {
  type: 'mongo',
  uri: '', // database connection uri
  database: '', // database name
})

const yogaLambda = new GraphQLServerLambda({
  typeDefs,
  resolvers,
})

export const graphql: Handler = (event: APIGatewayEvent, context: Context, callback: Callback) => {
  // allows function to re-use mongo connection for other events processed by this instance
  // https://www.mongodb.com/blog/post/optimizing-aws-lambda-performance-with-mongodb-atlas-and-nodejs
  context.callbackWaitsForEmptyEventLoop = false

  return yogaLambda.graphqlHandler(event, context, callback)
}

export const playground: Handler = (event: APIGatewayEvent, context: Context, callback: Callback) => {
  return yogaLambda.playgroundHandler(event, context, callback)
}

If you find any bugs or have a feature request, please open an issue on github!

The npm package download data comes from npm's download counts api and package details come from npms.io.