Ariadne toolkit for defining GraphQL schemas in modular fashion.
Project description
⚠️ Important Migration Warning: Version 1.0.0
With the release of version 1.0.0, there have been significant changes to the ariadne_graphql_modules
API. If you are upgrading from a previous version, you will need to update your imports to ensure your code continues to function correctly.
What You Need to Do
To maintain compatibility with existing code, you must explicitly import types from the v1
module of ariadne_graphql_modules
. This is necessary for any code that relies on the legacy API from versions prior to 1.0.0.
Example
Before upgrading:
from ariadne_graphql_modules import ObjectType, EnumType
After upgrading to 1.0.0:
from ariadne_graphql_modules.v1 import ObjectType, EnumType
Why This Change?
The introduction of version 1.0.0 brings a more robust and streamlined API, with better support for modular GraphQL schemas. To facilitate this, legacy types and functionality have been moved to the v1
submodule, allowing new projects to take full advantage of the updated architecture while providing a clear path for migrating existing codebases.
Ariadne GraphQL Modules
Ariadne GraphQL Modules is an extension for the Ariadne framework, designed to help developers structure and manage GraphQL schemas in a modular way. This library provides an organized approach to building GraphQL APIs by dividing your schema into self-contained, reusable modules, each responsible for its own part of the schema.
Installation
Ariadne GraphQL Modules can be installed using pip:
pip install ariadne-graphql-modules
Ariadne 0.23 or later is required for the library to work.
Basic Usage
Here is a basic example of how to use Ariadne GraphQL Modules to create a simple GraphQL API:
from datetime import date
from ariadne.asgi import GraphQL
from ariadne_graphql_modules import ObjectType, gql, make_executable_schema
class Query(ObjectType):
__schema__ = gql(
"""
type Query {
message: String!
year: Int!
}
"""
)
@staticmethod
def resolve_message(*_):
return "Hello world!"
@staticmethod
def resolve_year(*_):
return date.today().year
schema = make_executable_schema(Query)
app = GraphQL(schema=schema, debug=True)
In this example, a simple Query
type is defined within a module. The make_executable_schema
function is then used to combine the module into a complete schema, which can be used to create a GraphQL server.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for ariadne_graphql_modules-1.0.0.dev1.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 219ddc53d4a9b6d967a86668837d50e7ece997aa75ee70ae55bd74cc1baa081a |
|
MD5 | ed3e06a2eb9de494d9df0735cf515e14 |
|
BLAKE2b-256 | c2211f528c875022fcb0714ecd62602f7d30b0210d7b5904989d501f1c96943e |
Hashes for ariadne_graphql_modules-1.0.0.dev1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9facbfe362e0a0cf0aa6b426ac0c548b2b976cab36e4649eeb6cef2f81ad1588 |
|
MD5 | 83611322be37d827be6962620ee5ab47 |
|
BLAKE2b-256 | 44d396586aa8e2dd59cde5c7c7b5c3e589825b6a95b85114ba1da93373f57474 |