Skip to content

NREL/grapinator

Repository files navigation

Grapinator

Dynamic GraphQL API Creator for Python

Introduction

Grapinator is a dynamic api generator based on the Graphene library for building GraphQL query services. All you have to do to get a fully fuctional GraphQL service up and running is to configure a few setup files!

Key Features

  • No coding required: Utilizes Python metaprogramming so no additional coding is required to implement new GraphQL services!
  • Built with Flask-SQLAlchemy: Code based on the SQLAlchemy + Flask Tutorial examples.
  • Runtime configuration: Runtime configuration is managaged using the grapinator.ini file.
  • Flexable GraphQL schema definition: All Graphene and database information is provided by a Python dictionary that you change for your needs. Please review the schema documentation.
  • Additional query logic: More robust query logic has been added giving the api consumer more options to query for specific data.

Licensing

This project is licensed under the BSD 3-clause license.

Contributing

Allthough I use this code in production at my company, I consider it alpha code. If you have any ideas, just open an issue and tell me what you think, how it may be improved, bugs you may find, etc.

Getting Started

Demo

A sqlite database has been provided using the classic demo Northwind db. A grapinator schema definition file for this demo has been configured for this database as a playground and will be invoked during application startup via the default grapinator.ini file.

Follow the build instructions below to get the playground up and running. Once app.py is started, you will have a web service up and running on localhost:8443. You may use the built in GraphiQL web page to try some queries.

Development setup

Setup OSX/Linux

python -m venv venv
source venv/bin/activate
(venv) $ export $(cat .env)
(venv) $ pip install -e .
(venv) $ cd grapinator;python app.py

Setup using conda

conda create -n grapinator python
conda activate grapinator
(grapinator) $ conda install cx_Oracle
(grapinator) $ export $(cat .env)
(grapinator) $ pip install -e .
(grapinator) $ cd grapinator;python app.py

Running unit tests from the command line

Unit tests are located in the 'tests' directory. Integration tests are located in the 'tests_integration' directory.

python -m unittest [filename]