Registry / http-networking / graphql-sync-dataloaders

graphql-sync-dataloaders

JSON →
library0.1.1pypypi✓ verified 84d ago

Use DataLoaders in Python GraphQL servers that run in a synchronous context (e.g., Django). Current version 0.1.1. Infrequent releases.

pip install graphql-sync-dataloaders
INSTALL
IMPORT
SIG · GRAPHQL-SYNC-DATAL
G
graphql-sync-dataloaders
http-networkingpythonv0.1.1
Install
1.7s avg
Import
344ms
Disk
18MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v0.1.1 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.95 runs
installs and imports cleanly · install 0.0s · import 0.360s · 19.9MB
glibc
py 3.103.95 runs
installs and imports cleanly · install 1.7s · import 0.328s · 20MB
18MB installed
● package 18MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

SyncDataLoader
from graphql_sync_dataloaders import SyncDataLoader
from graphql_sync_dataloaders.decorators import SyncDataLoader
SyncDataLoader is directly exposed from the top-level package, not a submodule.

Example using SyncDataLoader with Django ORM. batch_load_fn must return a list of results parallel to keys.

from graphql_sync_dataloaders import SyncDataLoader class UserLoader(SyncDataLoader): def batch_load_fn(self, keys): # keys is a list of user IDs; return list of users in same order users = {user.id: user for user in User.objects.filter(id__in=keys)} return [users.get(key) for key in keys] loader = UserLoader() user = loader.load(1) # Synchronous call users = loader.load_many([1, 2, 3])
Debug
Known issues
gotchaSyncDataLoader.batch_load_fn must return a list of values in the exact same order as the input keys. Returning a dict and mapping may produce incorrect order.
fix
Always ensure batch_load_fn returns a list parallel to keys, using list comprehension or similar.
affects: >=0.1.0
deprecatedThe package has no known deprecations, but it is a very small library with low activity. Check for updates before relying on it for critical production systems.
fix
Monitor the GitHub repository for new releases or consider contributing fixes.
affects: >=0.1.0
Errors
Common errors & fixes
ImportError: cannot import name 'SyncDataLoader' from 'graphql_sync_dataloaders'
Incorrect import path or outdated version; SyncDataLoader is available from version 0.1.0 onwards.
fix
Upgrade to latest version: pip install --upgrade graphql-sync-dataloaders. Then import: from graphql_sync_dataloaders import SyncDataLoader
TypeError: batch_load_fn() missing 1 required positional argument: 'keys'
The batch_load_fn method signature expects exactly one argument (keys), but the class may not be properly subclassed or the method is defined incorrectly.
fix
Define batch_load_fn(self, keys) as a method of your subclass. Example: class MyLoader(SyncDataLoader):
    def batch_load_fn(self, keys):
        return [...]
Upgrade
Version history
0.1.1latest on PyPI · released Sep 28, 2022
Audit
Dependencies

No dependency data recorded yet.

Agent activity
13 hits · last 30 days
node
12
Resources
graphql-sync-dataloaders — pip install graphql-sync-dataloaders · libregistry