deploy orm django to a graphql API easily
Project description
Graphene-Django-Crud
Inspired by prisma-nexus and graphene-django-extras, This package turns the django orm into a graphql API
Installation
For installing graphene-django-crud, just run this command in your shell:
pip install graphene-django-crud
Documentation:
Simple usage
from django.contrib.auth.models import User, Group
from graphene_django_crud.types import DjangoGrapheneCRUD
import graphene
class UserType(DjangoGrapheneCRUD):
class Meta:
model = User
class Query(graphene.ObjectType):
user = UserType.ReadField()
users = UserType.BatchReadField()
class Mutation(graphene.ObjectType):
user_create = UserType.CreateField()
user_update = UserType.UpdatedField()
user_delete = UserType.DeleteField()
class Subscription(graphene.ObjectType):
pass
schema = graphene.Schema(
query=Query,
mutation=Mutation,
#subscription=Subscription
)
show the generated graphql schema
``` schema { query: Query mutation: Mutation }scalar DateTime
input DatetimeFilter {
equals: DateTime
in: [DateTime]
gt: DateTime
gte: DateTime
lt: DateTime
lte: DateTime
}
type ErrorType {
field: String!
messages: [String!]!
}
input IntFilter {
equals: Int
in: [Int]
gt: Int
gte: Int
lt: Int
lte: Int
contains: Int
startswith: Int
endswith: Int
regex: String
}
type Mutation {
userCreate(input: UserCreateInput!): UserMutationType
userUpdate(input: UserUpdateInput!, where: UserWhereUniqueInput!): UserMutationType
userDelete(where: UserWhereUniqueInput!): UserMutationType
}
type Query {
user(where: UserWhereUniqueInput): UserType
users(where: UserWhereWithOperatorInput, limit: Int, offset: Int, orderBy: [String]): UserNodeType
}
input StringFilter {
equals: String
in: [String]
contains: String
startswith: String
endswith: String
regex: String
}
input UserCreateInput {
password: String!
lastLogin: DateTime
isSuperuser: Boolean
username: String!
firstName: String
lastName: String
email: String
isStaff: Boolean
isActive: Boolean
dateJoined: DateTime
}
type UserMutationType {
ok: Boolean
errors: [ErrorType]
result: UserType
}
type UserNodeType {
count: Int
data: [UserType]
}
type UserType {
id: ID!
password: String
lastLogin: DateTime
isSuperuser: Boolean
username: String
firstName: String
lastName: String
email: String
isStaff: Boolean
isActive: Boolean
dateJoined: DateTime
}
input UserUpdateInput {
password: String
lastLogin: DateTime
isSuperuser: Boolean
username: String
firstName: String
lastName: String
email: String
isStaff: Boolean
isActive: Boolean
dateJoined: DateTime
}
input UserWhereUniqueInput {
id: ID
username: String
}
input UserWhereWithOperatorInput {
id: IntFilter
password: StringFilter
lastLogin: DatetimeFilter
isSuperuser: Boolean
username: StringFilter
firstName: StringFilter
lastName: StringFilter
email: StringFilter
isStaff: Boolean
isActive: Boolean
dateJoined: DatetimeFilter
OR: [UserWhereWithOperatorInput]
AND: [UserWhereWithOperatorInput]
NOT: UserWhereWithOperatorInput
}
```
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
graphene-django-crud-1.0.1.tar.gz
(14.9 kB
view hashes)
Close
Hashes for graphene-django-crud-1.0.1.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8e27bcb872a16de38ad4cc7bf3d8bec97f756256b1dae434901dc742c950df5f |
|
MD5 | 25c58103bacde14f3e207a88c82b0213 |
|
BLAKE2b-256 | a174e6b920c27aaf6c416b60b70431a9adbca020753c38a441346a40bcd5222c |