‚̧Nirvana Playing Madonna
Miss any of our Open RFC calls?Watch the recordings here! ¬Ľ

graphql-serve

1.0.1¬†‚Äʬ†Public¬†‚Äʬ†Published

Graphback


Auto generate database structure,
GraphQL Resolvers and Queries from GraphQL types ūüöÄ

Documentation: https://graphback.dev Repository: https://github.com/aerogear/graphback/

graphql-serve

Fully functional GraphQL Server based on Graphback CRUD Specification

graphql-serve is a full-featured GraphQL server, based on Graphback and Apollo Server. With the minimum configuration required, you have a server ready for testing GraphQL client applications or libraries. Unlike mocking alternatives, graphql-serve offers persistent data between queries and mutation using in-memory SQLite database.

Getting Started

Installation

Using npm:

npm install -g graphql-serve

or yarn:

yarn global add graphql-serve

Usage

gqlserve

The gqlserve command only needs one or more *.graphql data model file(s) in order to setup a working GraphQL server. Here is an example model file:

""" @model """
type Note {
  id: ID!
  title: String!
  description: String
  likes: Int
}

Assuming you have created your various *.graphql data model files in the models directory, to automatically generate resolvers and start a GraphQL server listening on port 8080 do the following:

$ gqlserve serve models --port=8080

If you only need to see the generated GraphQL Schema, use the print-schema command:

$ gqlserve print-schema .

The above command prints schema generated from data model files in the current directory.

This information is also provided with the command itself:

$ gqlserve -h
gqlserve <command>
 
Commands:
  gqlserve print-schema [modelDir]     Generate and print GraphQL schema from data
                                   model files
  gqlserve serve [modelDir] [options]  Generate and start GraphQL server from data
                                   model files
 
Options:
  -h, --help     Show help                                             [boolean]
  -v, --version  Show version number                                   [boolean]

For the serve command:

$ gqlserve serve -h
gqlserve serve [modelDir] [options]
 
Generate and start GraphQL server from data model files
 
Positionals:
  modelDir, model  Directory to search for data models                  [string]
 
Options:
  --port, -p        Specify the port on which to listen on              [number]
  --datasync, --ds  Enable datasynchronization features                [boolean]
  -h, --help        Show help                                          [boolean]
  -v, --version     Show version number                                [boolean]
 
Examples:
  gqlserve serve . -p 8080  generate schema from data model files in current
                            directory and start GraphQL server on port 8080

Also for print-schema command:

$ gqlserve print-schema -h
gqlserve print-schema [modelDir]
 
Generate and print GraphQL schema from data model files
 
Positionals:
  modelDir, model  Directory to search for data models                  [string]
 
Options:
  -h, --help     Show help                                             [boolean]
  -v, --version  Show version number                                   [boolean]
 
Examples:
  gqlserve print-schema modelDir  only display generated schema from data model
                              files in modelDir directory and quit

Under to hood we use Graphback to parse the Type Definitions/Data Model and generate the GraphQL schema and resolvers. See the Graphback Docs on Data Model Definition and Data Synchronization for data synchronization features.

Extension to GraphQL TestX

GraphQL serve is based on GraphQL-TestX: https://github.com/aerogear/graphql-testx

Keywords

none

Install

npm i graphql-serve

DownloadsWeekly Downloads

449

Version

1.0.1

License

Apache 2.0

Unpacked Size

48 kB

Total Files

45

Last publish

Collaborators

  • avatar
  • avatar
  • avatar
  • avatar