Time to read: 2 min read
A library for making GraphQL API with Python/Django. This is like a flash drive, just how you plug into computer and transfer files.
The tiny library is for making GraphQL in a minute. It considers models based approach. For example, Your app has few models like Book, Author, Publication etc. Now this library will enabled a GraphQL API for all those models. You can do query, mutation on API.
Example Query for "Book"
query getBooks {
bookList(limit: 500, name: "Honey") {
id
name
publication {
id
name
}
authors {
id
name
address
}
}
}
Example Create Mutation for "Book"
mutation CreateNewBook{
createbook(input:{
name: "GraphQL the awesomeness of API development",
authors: [1,7],
publication: 103
}) {
book{
id
name
authors{
id
name
}
publication {
id
name
}
}
}
}
Example Update Mutation for "Book"
mutation updateBook{
updatebook(id:2, input:{
name: "Hello Honey Bunny??"
authors: [1,2,3]
}) {
book{
id
name
publication{
name
}
authors {
id
name
}
}
}
}
Example Delete Mutation for "Book"
mutation deleteBook{
deletebook(id: 500){
book
}
}
Documentation is coming soon...
pip install pnp-graphql
GRAPHENE = {
'SCHEMA': 'pnp_graphql.schema.schema'
}
PNP_GRAPHQL = {
'ENABLED_APPS': ['example_app']
}
DEBUG = False
for production use.That's it 😃
Now visit: http://your-ip:port/api/graphql-explorer/ for explore GraphQL built-in UI explorer for query.
Production ready API : http://your-ip:port/api/graphql/
Contributors are most welcome 😃