Giter Site home page Giter Site logo

fractal-style-schema's Introduction

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).

fractal-style-schema's People

Contributors

cmmartti avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

fractal-style-schema's Issues

`auto` module catches all ImportErrors

The auto module silently catches all ImportErrors that occur past that point, even ones that happen in other modules. For example, if the auto module is trying to import module A in the try block, but module A tries to import a non-existent module X, module A is silently skipped.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.