0.1.17-dev.45 • Published 6 years ago

@currentdesk/prismatize v0.1.17-dev.45

Weekly downloads
9
License
MIT
Repository
github
Last release
6 years ago

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)
}
0.1.17-dev.45

6 years ago

0.1.17-dev.44

6 years ago

0.1.17-dev.43

6 years ago

0.1.17-dev.42

6 years ago

0.1.17-dev.41

6 years ago

0.1.17-dev.40

6 years ago

0.1.17-dev.39

6 years ago

0.1.17-dev.38

6 years ago

0.1.17-dev.37

6 years ago

0.1.17-dev.36

6 years ago

0.1.17-dev.35

6 years ago

0.1.17-dev.34

6 years ago

0.1.17-dev.32

6 years ago

0.1.17-30

6 years ago

0.1.17-29

6 years ago

0.1.17-28

6 years ago

0.1.17-27

6 years ago

0.1.17-26

6 years ago

0.1.17-25

6 years ago

0.1.17-24

6 years ago

0.1.17-23

6 years ago

0.1.17-22

6 years ago

0.1.17-21

6 years ago

0.1.17-20

6 years ago

0.1.17-19

6 years ago

0.1.17-15

6 years ago

0.1.17-14

6 years ago

0.1.17-13

6 years ago

0.1.17-12

6 years ago

0.1.17-11

6 years ago

0.1.17-10

6 years ago

0.1.17-9

6 years ago

0.1.17-8

6 years ago

0.1.17-7

6 years ago

0.1.17-6

6 years ago

0.1.17-5

6 years ago

0.1.17-1

6 years ago

0.1.17-0

6 years ago

0.1.16

6 years ago

0.1.16-6

6 years ago

0.1.16-5

6 years ago

0.1.16-4

6 years ago

0.1.16-3

6 years ago

0.1.16-2

6 years ago

0.1.16-1

6 years ago

0.1.16-0

6 years ago

0.1.15

6 years ago

0.1.14

6 years ago

0.1.13

6 years ago

0.1.11

6 years ago

0.1.10

6 years ago

0.1.9

6 years ago

0.1.8

6 years ago

0.1.7

6 years ago

0.1.6

6 years ago

0.1.5

6 years ago

0.1.4

6 years ago

0.1.3

6 years ago

0.1.2

6 years ago

0.1.1

6 years ago

0.1.0

6 years ago