Skip to content

Commit

Permalink
Update docs
Browse files Browse the repository at this point in the history
  • Loading branch information
juanjcardona13 committed Jul 18, 2024
1 parent 624b354 commit 2e52209
Show file tree
Hide file tree
Showing 6 changed files with 65 additions and 26 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ pip install graphene-django-cruddals

## <a name="usage">👩‍💻 Usage</a>

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

```python
Expand All @@ -72,7 +72,7 @@ class Choice(models.Model):
Then we can create a complete CRUD+DALS for the models `Question` with the following code

```python
class CruddalsQuestion(CruddalsModel):
class CruddalsQuestion(DjangoModelCruddals):
class Meta:
model = Question
```
Expand Down
57 changes: 53 additions & 4 deletions docs/docs/GET-STARTED/Quick-Start.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,62 @@ Hey there! Ready to start your project with graphene_django_cruddals? Awesome! I
1. Open up your favorite terminal.

2. Copy and paste the following command:
`pip install graphene_django_cruddals`
`pip install graphene_django_cruddals`

***Everything is ready!***

## Setup
## Basic usage

Once you've installed the package, you'll be ready to start! You **don't need to worry** about any additional configurations.
Want to see it in action? Head over to the [Basic Usage](../GUIDE-TUTORIALS/Basic-Usage.md) section to experience its first usage 🚀.
To use it, simply create a new class that inherits "`DjangoModelCruddals`"
Suppose we have the following model.

```python
class Restaurant(models.Model):
name = models.CharField(max_length=100)
slug = models.SlugField(max_length=100)
```

Then we can create a complete CRUD+DALS with the following code

```python
class CruddalsRestaurant(DjangoModelCruddals):
class Meta:
model = Restaurant
```

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

```python
schema = CruddalsRestaurant.Schema
```

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

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


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


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

and this is it, now you can go to Graphiql or your favorite graphql client and see the new queries and mutations that graphene django cruddals made for you

## Not working?

1. Don't forget to set the `graphene_django` in your project
2. Don't forget to set the url for the graphql view in your project


18 changes: 4 additions & 14 deletions docs/docs/GUIDE-TUTORIALS/Basic-Usage.md
Original file line number Diff line number Diff line change
@@ -1,28 +1,18 @@
## 💡 Basic usage

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

```python
class Restaurant(models.Model):
name = models.CharField(
max_length=100,
help_text='The name of the restaurant'
)
slug = models.SlugField(
help_text='The slug of the restaurant',
blank=True,
null=True,
unique=True,
editable=False,
max_length=100
)
name = models.CharField(max_length=100)
slug = models.SlugField(max_length=100)
```

Then we can create a complete CRUD+DALS with the following code

```python
class CruddalsRestaurant(CruddalsModel):
class CruddalsRestaurant(DjangoModelCruddals):
class Meta:
model = Restaurant
```
Expand Down
2 changes: 1 addition & 1 deletion docs/docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ graphene-django-cruddals is a **library** for [Django] that extends [Graphene-dj

First time using graphene-django-cruddals? We suggest starting with the [Quick-Start] to quickly set up your development environment and begin using the library in your project. Additionally, we recommend exploring the main documentation for [Graphene-django] to familiarize yourself with the basic utilities it offers.

[Quick-Start]:/GET%20STARTED/Quick-Start/
[Quick-Start]:GET-STARTED/Quick-Start.md
[Graphene-django]:https://docs.graphene-python.org/projects/django/en/latest/#
[Django]: https://www.djangoproject.com/

Expand Down
4 changes: 2 additions & 2 deletions docs/drafts/Quick-start.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ For installing graphene_django_cruddals, just run this command in your shell

## ℹ️ Basic usage

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

```python
Expand All @@ -31,7 +31,7 @@ Suppose we have the following model.
Then we can create a complete CRUD+DALS with the following code

```python
class CruddalsRestaurant(CruddalsModel):
class CruddalsRestaurant(DjangoModelCruddals):
class Meta:
model = Restaurant
```
Expand Down
6 changes: 3 additions & 3 deletions docs/drafts/step-by-step-installation.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@ To install Graphene Django CRUDDALS, follow these steps:
Install Graphene Django CRUDDALS with the virtual environment activated and in the project folder
`pip install graphene-django-cruddals`

In the schema.py file of the app, replace all content, import the CruddalsModel class, and create a class that inherits from it
In the schema.py file of the app, replace all content, import the DjangoModelCruddals class, and create a class that inherits from it

```python
from graphene_django_cruddals import CruddalsModel
from graphene_django_cruddals import DjangoModelCruddals
from .models import MyModel

class CruddalsMyModel(CruddalsModel):
class CruddalsMyModel(DjangoModelCruddals):
class Meta:
model = MyModel
```
Expand Down

0 comments on commit 2e52209

Please sign in to comment.