Skip to content

Add documentation for graphene-django-cruddals library to GraphQL Pyt… #1730

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 29, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
---
name: Graphene Django CRUDDALS
description: Turn your Django-models into a complete GraphQL API with all CRUD operations
url: https://graphene-django-cruddals.readthedocs.io/en/latest/
github: juanjcardona13/graphene_django_cruddals
---

You can install the package with pip

```bash
pip install graphene-django-cruddals
```

To use it, simply create a new class that inherits "`DjangoModelCruddals`"
Suppose we have the following models.

```python
from django.db import models


class Question(models.Model):
question_text = models.CharField(max_length=200)
pub_date = models.DateTimeField('date published')
is_active = models.BooleanField(default=True)
```

Then we can create a complete CRUD+DALS for the models `Question` with the following code

```python
from graphene_django_cruddals import DjangoModelCruddals

class CruddalsQuestion(DjangoModelCruddals):
class Meta:
model = Question
```

Now you can use the `schema` that was generated for you,

```python
schema = CruddalsQuestion.Schema
```

or use in your existing schema root `Query` and `Mutation`

```python
class Query(
# ... your others queries
CruddalsQuestion.Query,
graphene.ObjectType,
):
pass


class Mutation(
# ... your others mutations
CruddalsQuestion.Mutation,
graphene.ObjectType,
):
pass


schema = graphene.Schema( query=Query, mutation=Mutation, )
```

That's it! You can test in graphiql or any other client that you use to test your GraphQL APIs..

Find more information in the [official documentation](https://graphene-django-cruddals.readthedocs.io/en/latest/).
Loading