mirumee / ariadne-django Goto Github PK
View Code? Open in Web Editor NEWariadne_django makes integrating ariadne and django together easier.
License: BSD 3-Clause "New" or "Revised" License
ariadne_django makes integrating ariadne and django together easier.
License: BSD 3-Clause "New" or "Revised" License
Provide a rate limiting resolver decorator independent of any query calculations to help protect public queries and mutations. Ideally leverages django-ratelimit's existing functionality so the only compatibility layer is the decorator interface. django-ratelimit should be an optional install...
Provide a reference implementation for format_graphql_error that handles common errors (e.g. IntegrityError, SuspiciousOperation, ImproperlyConfigured, NotAuthenticated, PermissionDenied)
I find this to be a good way of setting up a delete by id:
type_defs = gql("""
type Document {
id:ID
name: String!
}
type DeleteResults{
success:[String]
errors:[String]
}
type Mutation{
DeleteDocument(input:[DocumentUpdate]): DeleteResults
}
"""
@mutation.field("DeleteDocument")
def DeleteDocument(*_, input):
deleted =[]
errors =[]
for inputs in input:
try:
id = inputs.get("id")
doc = Document.objects.get(pk=id)
deleted.append("id "+ id+": "+ doc.name +" document deleted")
doc.delete()
except Document.DoesNotExist:
errors.append("id: "+id+" not found")
return {'success': deleted, 'errors': errors}
For the function just replace the model Document
with whatever model. The results are the same for any model where a string is returned of the items you deleted and the errors. Is there a way some way to write the code so we can just plug in the django models to a function / class in this setup so less code is written? (I am not good at meta programming but find myself repeating this pattern)
Provide django-honeypot like functionality for public mutations (e.g. login, registration, etc.) views
Currently the timedelta
scalar serializer returns a float equivalent to the total amount of seconds.
It could be an idea to return the ISO format for durations (see https://en.wikipedia.org/wiki/ISO_8601#Durations). Since python doesn't implement a way to do timedelta(days=1).isoformat()
, we could use django duration_iso_string
:
from datetime import timedelta
from django.utils.duration import duration_iso_string
timedelta_scalar = ScalarType("Timedelta")
@timedelta_scalar.serializer
def serialize_timedelta(value: timedelta) -> float:
return duration_iso_string(value)
Also instead of Timedelta
it could be called Duration
Provide a class based form mutation resolver to allow simplified binding of Django REST Framework serializers to mutations.
Note: DRF should always be an optional install.
GraphQL queries can have somewhat painful to configure queries. We should provide a simple out of the box experience that handles queries at minimum, file uploads as a stretch goal.
Please check this discussion comment
mirumee/ariadne#625 (comment)
Are there any examples of how to deal with Manytomany fields?
Do I have to write a query to prefetch choice fields when updating the fields?
If django does it, we probably should too...
Provide a decorator that gives a django.contrib.auth.login_required like experience
Hi, can you add a tag/github release for the 0.3.0 package that was released today?
Thanks!
Provide scalar extension for common Django 'JSON' type.
Has anyone managed to get the graphql playground working with Django debug toolbar?
Provide a reference implementation with a simple Django application.
Why is the requirement pinned to 0.13? Any blockers?
I do not have simplejson
installed in my project. When i do ./manage.py makemigrations
, i get this error message:
File ".../urls.py", line 10, in <module>
from .schema import schema
File ".../schema.py", line 14, in <module>
from reportal.diagnostics.schema import schema as diagnostics_schema
File ".../diagnostics/schema.py", line 10, in <module>
from .graphql.bindings import bindables
File ".../diagnostics/graphql/bindings.py", line 9, in <module>
from ariadne_django.scalars import datetime_scalar
File ".../env/lib/python3.10/site-packages/ariadne_django/scalars/__init__.py", line 6, in <module>
from .json import json_scalar, parse_json_value, serialize_json
File ".../env/lib/python3.10/site-packages/ariadne_django/scalars/json.py", line 5, in <module>
import simplejson as json # supports decimals, etc.
ModuleNotFoundError: No module named 'simplejson'
Although it seems like simplejson
shouldn't even be a requirement, because json
in the standard library is simplejson
, isn't it?
json (originally called simplejson) was written by Bob Ippolito.
Provide a class based form mutation resolver to allow simplified binding of Django forms to mutations
I see a couple of changes have been made to the main branch since the last release - the one I was looking for was the change from simplejson
to json
. Is it possible to get a new release so I can update my requirements file to this with a numbered version?
I see the project is looking for new maintainers - I may be able to help out on this, if required.
Provide scalar extension for common Django 'UUID' type.
Provide documentation via readthedocs on how to install, configure, etc.
Provide a decorator that gives a django.contrib.auth.permission_required like experience
Provide scalar extension for common Django 'Decimal' type.
Now that Django supports async views, it would be good if ariadne_django included support for them.
I would propose this be implemented by adding an AsyncGraphQLView
class, and that as much code as possible is shared between it and GraphQLView
via mixins.
I plan to create a PR for this soon-ish, if nobody gets to it before me.
I've just about had it with writing import_module("resetbutton.graphql.query_type").type_defs,
into schema.py.
The presence of default_app_config
triggers a warning as of Django 3.2:
/usr/local/lib/python3.9/site-packages/django/apps/registry.py:91: RemovedInDjango41Warning: 'ariadne.contrib.django' defines default_app_config = 'ariadne.contrib.django.apps.AriadneConfig'. Django now detects this configuration automatically. You can remove default_app_config.
Maybe it makes sense to wrap this in a django.VERSION
check?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.