Git Product home page Git Product logo

ariadne-django's People

Contributors

aitorres avatar ccsv avatar dorianamouroux avatar drewsynan avatar maxmorlocke avatar smona 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  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  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  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

ariadne-django's Issues

Provide rate limiting

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

Deleting items by id

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)

Honeypot field

Provide django-honeypot like functionality for public mutations (e.g. login, registration, etc.) views

Change timedelta scalar to return ISO format

Currently the timedelta scalar serializer returns a float equivalent to the total amount of seconds.

https://github.com/reset-button/ariadne_django/blob/5a7c9d15a2b0e0baa8b7e7aad032c738a3dcd1fe/ariadne_django/scalars/timedelta.py#L10-L12

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 serializer mutation resolver

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.

Provide default test class

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.

Tag for the 0.3 release

Hi, can you add a tag/github release for the 0.3.0 package that was released today?

Thanks!

Ariadne 0.14

Why is the requirement pinned to 0.13? Any blockers?

Simplejson is required, but not listed in requirements.

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.

New release?

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.

Add async support

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.

default_app_config generates warning on Django 3.2+

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?

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.