Skip to content

An example of a Graphene-Python GraphQL schema where each entity is in its own module.

Notifications You must be signed in to change notification settings

cmmartti/fractal-style-schema

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Fractal-Style GraphQL Schema

This is an example of a fractal style GraphQL schema for Graphene-Python, where each entity is in its own module. Within each module are mutation, type, query, subscription, resolvers etc. files that contain all of the types, queries, mutations, etc. for that entity. This organisation method avoids the issue of overly-long schema files that contain dozens or hundreds of types and resolvers.

This specific example is a simple read-only query API for video games and characters.

The graphql_api.auto.schema_operations_builder function assembles each part into a whole Query/Mutation, which can then be passed to graphene.Schema to create a schema.

Circular dependencies are met using Graphene's lazy_import utility function.

Setup

This GraphQL API is built on Django. Follow the steps below to run it on your machine:

  1. Create a Python virtual environment:

    Python2: virtualenv venv

    Python3: python venv venv

  2. Activate the virtual environment:

    Windows: venv\Scripts\activate

    *nix: source venv/bin/activate

  3. Install dependencies:

    pip install -r requirements.txt

  4. Start the dev server:

    python manage.py runserver

  5. Open your browser to localhost:8000/graphql to view the GraphiQL IDE.


Based on code examples by ahopkins (Adam Hopkins) and ProjectCheshire (Jessamyn Hodge).

About

An example of a Graphene-Python GraphQL schema where each entity is in its own module.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages