graphql-relay-py is the Python port of the JavaScript Relay library for GraphQL, designed to facilitate the creation of Relay-compliant GraphQL servers using graphql-core. It provides utilities for global object identification (Nodes) and cursor-based pagination (Connections). The library maintains a regular release cadence, often aligning with updates to graphql-core and the upstream graphql-relay-js specification. The current version is 3.2.0.
pip install graphql-relay graphql-coreVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to set up a basic Relay-compliant GraphQL schema using `graphql-relay` with `graphene`. It includes defining a Node interface for global object identification and a Connection for pagination. It showcases `node_definitions`, `global_id_field`, `connection_definitions`, `connection_from_array`, and `connection_args`.
Migrate your graphql-core dependency to v3.x and update your graphql-relay-py imports and API calls as necessary. Review the graphql-core and graphql-relay-py v3 release notes for specific changes. This also requires Python 3.6+.
Ensure that your `graphql-relay-py` version matches the expected `graphql-core` major version. For new projects, use `graphql-relay-py` v3.x with `graphql-core` v3.x.
For new code, prefer importing connection-related utilities like `connection_from_array` directly from the top-level `graphql_relay` package. If you must use `arrayconnection`, ensure your version is `3.1.5` or later, or adapt to `array_connection` if on affected versions.
Update your code to handle `unbase64` returning an empty string for invalid inputs if you were previously relying on exceptions for error handling. Review `from_global_id` usage, especially if parsing IDs from external sources.
Ensure 'graphene' is installed in your Python environment, e.g., by running `pip install graphene`.
Ensure that the `graphene` package is installed in your environment. You can typically install it using `pip install graphene`.