Turn your API made with Django REST Framework(DRF) into a GraphQL like API.

Overview

Django RESTQL

Build Status Latest Version Python Versions License        Downloads Downloads Downloads

Django RESTQL is a python library which allows you to turn your API made with Django REST Framework(DRF) into a GraphQL like API. With Django RESTQL you will be able to

  • Send a query to your API and get exactly what you need, nothing more and nothing less.

  • Control the data you get, not the server.

  • Get predictable results, since you control what you get from the server.

  • Get nested resources in a single request.

  • Avoid Over-fetching and Under-fetching of data.

  • Write(create & update) nested data of any level in a single request.

Isn't it cool?.

Want to see how this library is making all that possible?

Check out the full documentation at https://yezyilomo.github.io/django-restql

Or try a live demo on Django RESTQL Playground

Requirements

  • Python >= 3.6
  • Django >= 1.11
  • Django REST Framework >= 3.5

Installing

pip install django-restql

Getting Started

Using Django RESTQL to query data is very simple, you just have to inherit the DynamicFieldsMixin class when defining a serializer that's all.

from rest_framework import serializers
from django.contrib.auth.models import User
from django_restql.mixins import DynamicFieldsMixin


class UserSerializer(DynamicFieldsMixin, serializer.ModelSerializer):
    class Meta:
        model = User
        fields = ['id', 'username', 'email']

Django RESTQL handle all requests with a query parameter, this parameter is the one used to pass all fields to be included/excluded in a response. For example to select id and username fields from User model, send a request with a query parameter as shown below.

GET /users/?query={id, username}

[
    {
        "id": 1,
        "username": "yezyilomo"
    },
    ...
]

Django RESTQL support querying both flat and nested resources, so you can expand or query nested fields at any level as defined on a serializer. In an example below we have location as a nested field on User model.

from rest_framework import serializers
from django.contrib.auth.models import User
from django_restql.mixins import DynamicFieldsMixin

from app.models import GroupSerializer, LocationSerializer


class LocationSerializer(DynamicFieldsMixin, serializer.ModelSerializer):
    class Meta:
        model = Location
        fields = ['id', 'country',  'city', 'street']


class UserSerializer(DynamicFieldsMixin, serializer.ModelSerializer):
    location = LocationSerializer(many=False, read_only=True) 
    class Meta:
        model = User
        fields = ['id', 'username', 'email', 'location']

If you want only country and city fields on a location field when retrieving users here is how you can do it

GET /users/?query={id, username, location{country, city}}

[
    {
        "id": 1,
        "username": "yezyilomo",
        "location": {
            "contry": "Tanzania",
            "city": "Dar es salaam"
        }
    },
    ...
]

You can even rename your fields when querying data, In an example below the field location is renamed to address

GET /users/?query={id, username, address: location{country, city}}

[
    {
        "id": 1,
        "username": "yezyilomo",
        "address": {
            "contry": "Tanzania",
            "city": "Dar es salaam"
        }
    },
    ...
]

Documentation 📝

You can do a lot with Django RESTQL apart from querying data, like

  • Rename fields
  • Restrict some fields on nested fields
  • Define self referencing nested fields
  • Optimize data fetching on nested fields
  • Data filtering and pagination by using query arguments
  • Data mutation(Create and update nested data of any level in a single request)

Full documentation for this project is available at https://yezyilomo.github.io/django-restql, you are advised to read it inorder to utilize this library to the fullest.

Django RESTQL Play Ground

Django RESTQL Play Ground is a graphical, interactive, in-browser tool which you can use to test Django RESTQL features like data querying, mutations etc to get the idea of how the library works before installing it. It's more like a live demo for Django RESTQL, it's available at https://django-restql-playground.yezyilomo.me

Running Tests

python runtests.py

Credits

  • Implementation of this library is based on the idea behind GraphQL.
  • My intention is to extend the capability of drf-dynamic-fields library to support more functionalities like allowing to query nested fields both flat and iterable at any level and allow writing on nested fields while maintaining simplicity.

Contributing PRs Welcome

We welcome all contributions. Please read our CONTRIBUTING.md first. You can submit any ideas as pull requests or as GitHub issues. If you'd like to improve code, check out the Code Style Guide and have a good time!.

Comments
  • Creating a related object when using PATCH method raises a server error

    Creating a related object when using PATCH method raises a server error

    Let's say I have these models:

    class Address(models.Model):
        street = models.CharField()
        city = models.CharField()
        postcode = models.CharField()
    
    class Person(models.Model):
        address = models.ForeignKey('Address', null=True, blank=True, on_delete=models.SET_NULL)
        ... other fields ...
    

    (note that all the fields in the Address model are required)

    The address field is a NestedField in my serializer

    class PersonSerializer(DynamicFieldsMixin, NestedModelSerializer):
        address = NestedField(AddressSerializer, allow_null=True, required=False)
    

    When I create a Person object with address being null and then want to add the address later using a PATCH method with some of the fields missing, PATCH /api/person/1/

    {
        "address": {"street": "Main street 1"}
    }
    

    I get a server error.

    File "E:\Documents\Work\hriis-crm\backend\.venv\lib\site-packages\rest_framework\serializers.py", line 200, in save
        self.instance = self.update(self.instance, validated_data)
      File "E:\Documents\Work\hriis-crm\backend\.venv\lib\site-packages\django_restql\mixins.py", line 985, in update
        fields["foreignkey_related"]["writable"]
      File "E:\Documents\Work\hriis-crm\backend\.venv\lib\site-packages\django_restql\mixins.py", line 756, in update_writable_foreignkey_related
        obj = serializer.save()
      File "E:\Documents\Work\hriis-crm\backend\.venv\lib\site-packages\rest_framework\serializers.py", line 178, in save
        'You cannot call `.save()` on a serializer with invalid data.'
    AssertionError: You cannot call `.save()` on a serializer with invalid data.
    

    When I use a PUT method, I get a normal HTTP 400 response with validation messages.

    {
      "address": {
        "city": [
          "This field is required."
        ],
        "postcode": [
          "This field is required."
        ]
      }
    }
    
    bug 
    opened by sommelon 27
  • Getting last related object

    Getting last related object

    Not sure if this is an issue or I'm just doing something wrong. My models:

    class Application(models.Model):
        customer = models.ForeignKey("Customer",
                                     related_name="applications",
                                     on_delete=models.CASCADE)
        status = models.CharField(max_length=50,
                                  choices=ApplicationStatus.choices,
                                  default=ApplicationStatus.INCOMPLETE)
    
    
    class Partner(models.Model):
        name = models.CharField(max_length=31)
    
    
    class Offer(models.Model):
        application = models.ForeignKey("core.Application",
                                        related_name="offers",
                                        on_delete=models.CASCADE)
        partner = models.ForeignKey("core.Partner",
                                    related_name="partners",
                                    on_delete=models.CASCADE)
        status = models.CharField(max_length=50,
                                  choices=OfferStatus.choices,
                                  default=OfferStatus.NEW)
    
    
    class Customer(models.Model):
        """ Customer model """
    
        first_name = models.CharField(max_length=31)
        last_name = models.CharField(max_length=31)
    

    serializers:

    class PartnerSerializer(DynamicFieldsMixin, serializers.ModelSerializer):
        class Meta:
            model = Partner
            fields = ["id", "name"]
    
    
    class OfferSerializer(DynamicFieldsMixin, serializers.ModelSerializer):
        partner = PartnerSerializer(read_only=True)
    
        class Meta:
            model = Offer
            fields = ["id", "partner", "status"]
    
    
    class ApplicationSerializer(DynamicFieldsMixin, serializers.ModelSerializer):
        """ Application serializer """
    
        offers = OfferSerializer(many=True, read_only=True)
    
        class Meta:
            model = Application
            fields = [
                "id", "customer", "offers", "status"
            ]
    
    
    class CustomerSerializer(DynamicFieldsMixin, serializers.ModelSerializer):
        """ Customer serializer """
    
        applications = ApplicationSerializer(many=True, read_only=True)
    
        class Meta:
            model = Customer
            fields = [
                "id",
                "first_name",
                "last_name",
            ]
    

    and views:

    class ApplicationViewSet(ModelViewSet):
        serializer_class = ApplicationSerializer
        queryset = Application.objects.all()
        filter_fields = {"status": ["icontains"]}
    
    
    class CustomerViewSet(ModelViewSet):
        serializer_class = CustomerSerializer
        queryset = Customer.objects.all()
        filter_fields = {
            "first_name": ["icontains"],
            "last_name": ["icontains"],
            "applications__status": ["exact"],
        }
    
    
    class PartnerViewSet(ModelViewSet):
        serializer_class = PartnerSerializer
        queryset = Partner.objects.all()
    
    
    class OfferViewSet(ModelViewSet):
        serializer_class = OfferSerializer
        queryset = Offer.objects.all()
    

    And the issue is that query /api/v2/customers/?query=(first_name:Mirdza){id,first_name,last_name,applications(status:INCOMPLETE){id,status}} returns data like this:

    		{
                "id": 1,
                "first_name": "Mirdza",
                "last_name": "Kalniņa",
                "applications": [
                    {
                        "id": 1,
                        "status": "POSITIVE_OFFERS"
                    }
                ]
            },
            {
                "id": 2,
                "first_name": "Jūla",
                "last_name": "Krūmiņa",
                "applications": [
                    {
                        "id": 2,
                        "status": "NO_ACTION"
                    },
                    {
                        "id": 3,
                        "status": "WAITING_MORE_INFO"
                    },
                    {
                        "id": 4,
                        "status": "WAITING_MORE_INFO"
                    }
                ]
            },
    		{
                "id": 3,
                "first_name": "Mirdza",
                "last_name": "Roze",
                "applications": [
                    {
                        "id": 9,
                        "status": "INCOMPLETE"
                    }
                ]
            },
    ...
    

    What I expected was:

    		{
                "id": 3,
                "first_name": "Mirdza",
                "last_name": "Roze",
                "applications": [
                    {
                        "id": 9,
                        "status": "INCOMPLETE"
                    }
                ]
            },
    

    First of all I want always to get the last application for a customer and in case of the given query, only customers who have last application in a given status. Is it even possible to achieve that?

    opened by andis-roze 24
  • does not work with SerializerMethodField

    does not work with SerializerMethodField

    In case when i use one to many fields i need to pass serializer's id into different serializer.

    def get_a_list(self, obj):
        child = b.objects.all()
        serializer = BListSerializer(instance=child, context={"obj_id": obj.id}, many=True)
        return serializer.data
    
    opened by oguzhancelikarslan 23
  • Allow excluding fields when querying

    Allow excluding fields when querying

    When using restql, we found that the filtering as-is is great if there are not a high number of fields. But sometimes we have a case where we'd like everything except a handful of fields on a larger serializer. These fields might be nested and trying the whitelist approach is difficult or possibly too long for the url.

    Thoughts on either adding an additional query param for exclusion (such as exclude=...?) or providing some syntax to specify exclusion (something like {course{-books}})?

    Definitely willing to help implement, just curious if there's a solid enough case for it. Exclusion doesn't seem too out there to integrate into the field logic on the mixin.

    opened by tredzko 21
  • `fields` kwarg conflicts with a FK NestedField with `accept_pk` kwarg when updating

    `fields` kwarg conflicts with a FK NestedField with `accept_pk` kwarg when updating

    I'm running into an issue when PATCHing or PUTing a resource with a nested serializer. For brevity, here's an example:

    class EmployeeJobDetailSerializer(DynamicFieldsMixin, NestedModelSerializer):
    	employee = NestedField(
    		EmployeeSerializer,
    		accept_pk=True,
    		fields=['employee_id', 'first_name', 'last_name']
    	)
    
        class Meta:
            model = EmployeeJobDetail
    		fields = ...
    

    If I'm not mistaken, accept_pk=True essentially converts the nested serializer to a PrimaryKeyRelatedField when creating/updating. However, PrimaryKeyRelatedField does not recognize the fields argument so it throws an error: TypeError: __init__() got an unexpected keyword argument 'fields'.

    Is there a way to somehow ignore fields when updating with accept_pk=True? GET works perfectly and only selects the fields that I have specified for the kwarg.

    opened by resurrexi 20
  • PATCHing does not work with NestedFields, when the NestedField is omitted

    PATCHing does not work with NestedFields, when the NestedField is omitted

    I've installed this latest version that was to resolve this issue, and am trying to patch again, but still getting (new) errors.

    Following the example in the original issue with AccountSerializer nesting a ClientSerializer, I am trying to patch to update other attributes of the Account (completely omitting client in my request body), and getting the following error: ValueError: Cannot assign "<class 'rest_framework.fields.empty'>": "Account.client" must be a "Client" instance.

    It seems that while the request does not have client in the JSON, the serializer's validated_data does, with a value of the rest_framework.fields.empty class.

    I presume your updated tests covered this case, could I be doing something wrong?

    Originally posted by @TheUKDave in https://github.com/yezyilomo/django-restql/issues/143#issuecomment-617774153

    opened by TheUKDave 14
  • Updating a serializer won't work without the foreign key

    Updating a serializer won't work without the foreign key

    Awesome library, love what you're doing here.

    My only challenge is updating parent model without adding the child key. So, if I just want to PATCH one field on the Room model below, like the name, I don't want to have to add the castle id as well to the main body call. Here's the code

    serializers.py

    class CastleSerializer(DynamicFieldsMixin, serializers.ModelSerializer):
        class Meta:
            model = Castle
            fields = '__all__'
    
    class RoomSerializer(DynamicFieldsMixin, NestedModelSerializer):
        castle = NestedField(CastleSerializer, accept_pk=True)
    
        class Meta:
            model = Room
            fields = ('id', 'name', 'castle')
    

    I would expect to be able to POST or PATCH an update method without having to add the nested castle id and have it just validate and work.

    API call: PATCH /api/v1/rooms-update/

    [
      {
        "id": 1,
        "name": "Throne Room Changed Text",
      }
    ]
    

    should return

    [
      {
        "id": 1,
        "name": "Throne Room Changed Text",
        "castle": {
            "id": 1,
            "name": "Daventry Castle"
        }
      }
    ]
    
    

    It seems none of this is currently working, but when I add the castle primary key, it works just fine. I could change the

    castle = NestedField(CastleSerializer, accept_pk=True)
    

    to

    castle = NestedField(CastleSerializer, required=False, allow_null=True)
    

    but that would update the castle field to null, when instead I want it to keep it's previous value (since it's not part of the body text).

    How do I go about this?

    opened by lesreaper 12
  • Minor bug in NestedField if nested serializer allows empty data

    Minor bug in NestedField if nested serializer allows empty data

    I ran into an issue using NestedFields when it wraps a serializer that allows no data body when POSTing.

    What I want to be able to achieve is embed the a serializer as a nested serializer in another serializer. With this nested serializer, I want to be able to either:

    1. Automatically create the instance for the nested serializer if no data is available for the serializer.
    2. Create the instance if data is available for the nested serializer.

    The problem I face is that in order to achieve bullet point 1, I can't wrap the nested serializer field in NestedField, and I would have to then override create and update in the parent serializer to achieve bullet point 2.

    As an example, consider the following model definitions and their serializer:

    # models.py
    from django.db import models
    from django.utils.crypto import get_random_string
    from django.utils.timezone import now
    
    
    class LotNumber(models.Model):
        lot_number = models.CharField(max_length=6, primary_key=True, blank=True)
        is_active = models.BooleanField(default=True)
        created_at = models.DateTimeField(auto_now_add=True)
        updated_at = models.DateTimeField(auto_now=True)
    
        @staticmethod
        def _generate_lot_number(length=6):
            return get_random_string(length=length)
    
        def save(self, *args, **kwargs):
            if not self.lot_number:
                self.lot_number = self._generate_lot_number(length=6)
            super().save(*args, **kwargs)
    
    
    class Inventory(models.Model):
        sku_code = models.CharField(max_length=32)
        lot_number = models.ForeignKey(LotNumber, blank=True, null=True, on_delete=models.PROTECT)
        finish_date = models.DateField(default=now)
    
        def save(self, *args, **kwargs):
            if not self.lot_number:
                lot_class = self._meta.get_field("lot_number").related_model
                new_lot = lot_class.objects.create()
                self.lot_number = new_lot
            super().save(*args, **kwargs)
    
    
    # serializers.py
    from rest_framework import serializers
    
    from django_restql.serializers import NestedModelSerializer
    from django_restql.fields import NestedField
    
    from .models import LotNumber, Inventory
    
    
    class LotNumberSerializer(serializers.ModelSerializer):
        class Meta:
            model = LotNumber
            fields = "__all__"
    
    
    class InventorySerializer(serializers.ModelSerializer):
        lot_number = LotNumberSerializer(required=False)
    
        class Meta:
            model = Inventory
            fields = "__all__"
    
    
    class NestedInventorySerializer(NestedModelSerializer):
        lot_number = NestedField(LotNumberSerializer, required=False)
    
        class Meta:
            model = Inventory
            fields = "__all__"
    

    If I were to make a POST request at the InventorySerializer endpoint, I would be able to create an Inventory instance without passing data for the lot_number field because the save method in the LotNumber model automatically creates the data. The LotNumberSerializer would also consider the empty data as valid. The response would be something like:

    {
        "id": 1,
        "sku_code": "ABC-PRODUCT",
        "lot_number": {
    	    "lot_number": "P519CK",
            "is_active": true,
            "created_at": "2020-03-18T12:12:39.943000Z",
            "updated_at": "2020-03-18T12:12:39.943000Z"
        }
    }
    

    This only achieves bullet point 1 from earlier. If I wanted to inject my own lot_number value, I have to override the create and update methods in InventorySerializer, which complicates things.

    Now, if I were to make a POST request at the NestedInventorySerializer endpoint, I would be able to create the Inventory instance if I did pass data for the lot_number field. However, if I attempt bullet point 1 on this serializer, I get the following response:

    {
        "lot_number": {
            "non_field_errors": [
                "No data provided"
            ]
        }
    }
    

    I found a temporary fix whereby requiring the lot_number field in the parent serializer and setting a default={} on the field resolved the problem. However I don't think this aligns with the intent of the NestedField wrapper, where arguments should behave the same way as when the wrapper is not used.

    Instead, I think the fix for this is in fields.py in the to_internal_value method of the BaseNestedFieldSerializer class. Specifically in line 278, the code should be data = {}. Technically, the code could be moved to line 275 and lines 276-278 can be deleted. This fix should not affect scenarios where a nested serializer does require data and data isn't passed, due to the fact that calling is_valid in this scenario will return False.

    opened by resurrexi 12
  • Support prefetching and selecting related fields dynamically according to a query parameter

    Support prefetching and selecting related fields dynamically according to a query parameter

    Hey there!

    Have started recently using the project and super impressed! Very helpful to be able to narrow down the fields returned on the fly.

    One consideration my team and I had was about trying to properly prefetch_related/select_related when we are or are not including fields. For example, if a Course has books, but we only ask for id, then we should not prefetch books. But if we do include books, we definitely want to prefetch them to prevent the list queries from getting out of control.

    We have made our own internal implementation and mixin, but wanted to gauge interest and make sure we take any cases we haven't run into yet into consideration. Thoughts?

    opened by tredzko 12
  • Is there an option to turn off the dynamic fields option (DynamicFieldsMixin) even when passing the query?

    Is there an option to turn off the dynamic fields option (DynamicFieldsMixin) even when passing the query?

    We recently run into a situation that the children serializer break inside the to_representation method. For example

    class ParentSerializer(DynamicFieldsMixin, serializer.ModelSerializer):
        ...
        def to_representation(self, instance):
            representation = super().to_representation(instance)
            # Manually set the representation here. Imagine that we need to do some extra work that can't be put
            # into a serializer method field for some reason.
            # Because we pass `self.context`, any restql querying is using the parent query fields, so those fields
            # might not exist on the child, which raises a parser error.
            representation["children"] = ChildSerializer(data=instance.child, context=self.context)
    class ChildSerializer(DynamicFieldsMixin, serializers.ModelSerializer)
    

    As a result, ChildSerializer did not work because it did not pass correct data in the query params which were for the parent serializer. I wonder if we have an option to toggle dynamic field functionality when instantiating the serializer?

    Thanks, Tao

    opened by daidaitaotao 11
  • Link bug in docs

    Link bug in docs

    I just wanted to say that I discovered your package recently and I'm absolutely blown away with what it can do. I was actually thinking of switching from drf to graphene until I found your repo. I'm so impressed I actually want to donate to your project.

    Anyways, aside from my impressions, I was looking through your docs and found one minor bug in a section under the Settings tab: https://django-restql.yezyilomo.com/settings/#default_base_filter_backend

    In that section, there is a dead link, Filtering with query arguments. I believe that link should point to http://django-restql.yezyilomo.com/querying_data/#filtering-with-query-arguments

    I can fix the bug and submit a PR if you want.

    opened by resurrexi 9
  • DynamicMethodField issue with onetoMany and many2many object not iteration

    DynamicMethodField issue with onetoMany and many2many object not iteration

    My orm requirement some time get reference of one2Many and Many2Many Object Reference. DynamicMethodField refere of 'obj' to get onetomany object references rto get perent table not accible using mcourse.authors or mcourse.id ,mcourse.* not accessible like modelSerializer Method operation.. Can you check and resolve issue...

    opened by obularajud 1
  • Update method doesn't raise a serializer error on save with invalid data.

    Update method doesn't raise a serializer error on save with invalid data.

    I am trying to created an object from a nested field, using a patch request. Basically there exist one to many relationship between them, and also a unique together constrain at the model level.

    url: PATCH: http://127.0.0.1:8000/api/v2/product_batches/11791/

    Payload:

    {
        "ingredient_mixes":{
            "create":[{
                "ingredient": 23,
                "quantity": 3,
                "unit_of_measurement": "kg",
                "product_batch": 11791,
                "is_removed": false,
                "removed_at": "2021-11-18T21:58:39.512Z",
                "remote_id": null
            },
            {
                "ingredient": 17,
                "quantity": 100,
                "unit_of_measurement": "L",
                "product_batch": 11791,
                "is_removed": false,
                "removed_at": "2021-11-18T21:58:39.512Z",
                "remote_id": null
            }]
        }
    }
    

    When I try to create an object that break the unique together constrain, let's that send again the same payload. The update method, get and an error from the serializer.

    Screen Shot 2022-04-01 at 10 42 41 AM

    Because the data is not valid, It violates the unique together constrain as I expect, but the request return a 500 code with the following message: "AssertionError: You cannot call .save() on a serializer with invalid data" Instead of return serializers.ValidationError. Is this behaviour what are you expecting? I would like to handle that error, I think in override the update method and put one try and except in order to catch the ValidationError and return a custom message. Do you have any suggestion to this? Thank you!

    opened by jalondono 0
  • Is it possible to exclude fields by default?

    Is it possible to exclude fields by default?

    Is it possible to exclude fields by default? I have a serializer with a serialized field with a lot of data. This data will be used in some specific cases, but not always.

    class BookSerializer(DynamicFieldsMixin, serializer.ModelSerializer):
        ....
    
        class Meta:
            model = Book
            fields = ['id', 'name',  '...']
    
    class UserSerializer(DynamicFieldsMixin, serializer.ModelSerializer):
        books = BookSerializer(many=True, read_only=True)
        ....
    
        class Meta:
            model = User
            fields = ['id', 'username', 'email', '...', 'books']
    

    Imagine a user with 500 books. In my logic I normally don't need to know information about those 500 books, but I do need to know information about the user (this is not a real example).

    I could exclude using the query GET /user/1?query={username, -books} but it forces me to put it everywhere where it is consumed.

    The idea would be something like:

    class UserSerializer(DynamicFieldsMixin, serializer.ModelSerializer):
        books = BookSerializer(many=True, read_only=True)
        ....
    
        class Meta:
            model = User
            fields = ['id', 'username', 'email', '...', 'books']
            default_exclude = ['books']
    

    Default:

     # `GET /user/1`
    
    {
        "id": 100
        "username": "dummy",
        "....": "....", # without the "books" field
    },
    

    With books field:

     # `GET /user/1?query={id, username, books}`
    
    {
        "id": 100
        "username": "dummy",
        "books": [ ..... ]
    }
    

    Thank you for everything!

    opened by Alejandroid17 1
  • Auto schema generation

    Auto schema generation

    Hello there,

    thanks for the great library. Our frontend team is now looking into integrating the newly enabled queries. A GraphQL schema would be awesome for something like https://www.graphql-code-generator.com to automatically generate a lot of boilerplate code.

    Is there support or a workaround for this? Technically all the data is there. Graphene offers it like this: ./manage.py graphql_schema --schema tutorial.quickstart.schema --out schema.json

    Side question: the playground offers a single endpoint /get/ and takes a specified model. How would I integrate something like that (which is even closer to "standard" graphql) into my backend?

    Thanks in advance!

    opened by aprams 0
  • Query by nested field not working

    Query by nested field not working

    I am trying get a field from nested object, but always get all nested fields from it.

    request example: request?query={id, name, book{id} } return: { id: 1235 name: testing book{ id: 45 name: book test pages: 454 } }

    it happens with someone as well?

    opened by caiquestow 1
  • Querying data not working as expected

    Querying data not working as expected

    While trying out querying data on the playground, I could not get the excepted result. For example, I chose Course model on the playground and tried to query by book ID, like this: { id, name, code, books(id:3) { id, title, author, genre { id, title, description } } }

    It returns all courses. But if I try to query by course id, like this: (id:1) { id, name, code, books { id, title, author, genre { id, title, description } } }

    It works as excepted. Tried it out on some of the offered models, but I could not get consistent result...sometimes it works as excepted, and in some cases (like this one) it does not. How does this exactly work?

    opened by mario-maistra 1
Releases(v0.15.3)
Owner
Yezy Ilomo
Building cool stuffs with Python and JavaScript.
Yezy Ilomo
Django-rest-auth provides a set of REST API endpoints for Authentication and Registration

This app makes it extremely easy to build Django powered SPA's (Single Page App) or Mobile apps exposing all registration and authentication related functionality as CBV's (Class Base View) and REST (JSON)

Tivix 2.4k Dec 29, 2022
Document Web APIs made with Django Rest Framework

DRF Docs Document Web APIs made with Django Rest Framework. View Demo Contributors Wanted: Do you like this project? Using it? Let's make it better! S

Manos Konstantinidis 626 Nov 20, 2022
Country-specific Django helpers, to use in Django Rest Framework

django-rest-localflavor Country-specific serializers fields, to Django Rest Framework Documentation (soon) The full documentation is at https://django

Gilson Filho 19 Aug 30, 2022
Scaffold django rest apis like a champion 🚀

scaffold django rest apis like a champion ??

Abdenasser Elidrissi 133 Jan 5, 2023
Generate Views, Serializers, and Urls for your Django Rest Framework application

DRF Generators Writing APIs can be boring and repetitive work. Don't write another CRUDdy view in Django Rest Framework. With DRF Generators, one simp

Tobin Brown 332 Dec 17, 2022
JSON:API support for Django REST framework

JSON:API and Django REST framework Overview JSON:API support for Django REST framework Documentation: https://django-rest-framework-json-api.readthedo

null 1k Dec 27, 2022
simple api build with django rest framework

Django Rest API django-rest-framework Employees management simple API in this project wrote test suites for endpoints wrote simple doc string for clas

OMAR.A 1 Mar 31, 2022
Simple Crud Api With Django Rest Framework

SIMPLE CRUD API WITH DJANGO REST FRAMEWORK Django REST framework is a powerful and flexible toolkit for building Web APIs. Requirements Python 3.6 Dja

kibet hillary 1 May 3, 2022
BloodDonors: Built using Django REST Framework for the API backend and React for the frontend

BloodDonors By Daniel Yuan, Alex Tian, Aaron Pan, Jennifer Yuan As the pandemic raged, one of the side effects was an urgent shortage of blood donatio

Daniel Yuan 1 Oct 24, 2021
RESTler is the first stateful REST API fuzzing tool for automatically testing cloud services through their REST APIs and finding security and reliability bugs in these services.

RESTler is the first stateful REST API fuzzing tool for automatically testing cloud services through their REST APIs and finding security and reliability bugs in these services.

Microsoft 1.8k Jan 4, 2023
Mlflow-rest-client - Python client for MLflow REST API

Python Client for MLflow Python client for MLflow REST API. Features: Minimal de

MTS 35 Dec 23, 2022
Authentication for Django Rest Framework

Dj-Rest-Auth Drop-in API endpoints for handling authentication securely in Django Rest Framework. Works especially well with SPAs (e.g React, Vue, Ang

Michael 1.1k Dec 28, 2022
A JSON Web Token authentication plugin for the Django REST Framework.

Simple JWT Abstract Simple JWT is a JSON Web Token authentication plugin for the Django REST Framework. For full documentation, visit django-rest-fram

Jazzband 3.3k Jan 4, 2023
Automated generation of real Swagger/OpenAPI 2.0 schemas from Django REST Framework code.

drf-yasg - Yet another Swagger generator Generate real Swagger/OpenAPI 2.0 specifications from a Django Rest Framework API. Compatible with Django Res

Cristi Vîjdea 3k Jan 6, 2023
Introduction to Django Rest Framework

Introduction to Django Rest Framework This is the repository of the video series Introduction to Django Rest Framework published on YouTube. It is a s

Simple is Better Than Complex 20 Jul 14, 2022
Swagger Documentation Generator for Django REST Framework: deprecated

Django REST Swagger: deprecated (2019-06-04) This project is no longer being maintained. Please consider drf-yasg as an alternative/successor. I haven

Marc Gibbons 2.6k Dec 23, 2022
Recursive Serialization for Django REST framework

djangorestframework-recursive Overview Recursive Serialization for Django REST framework This package provides a RecursiveField that enables you to se

null 336 Dec 28, 2022
Dropdown population implementation for Django REST Framework

drf-dropdown Dropdown population implementation for Django REST Framework Usage Add DropdownView to API URL # urls.py import dropdown urlpatterns = [

Preeti Yuankrathok 4 Dec 6, 2022