I'm looking into develop a GraphQL API. I have a django/elasticsearch/mysql backend and I'm figuring out how GraphQL fits into this picture.
I reading about the graphene-django project but it seems tightly coupled with the Django ORM, so I'm wondering if elasticsearch can fits in this recipe.
I'm just starting this research so there is a chance that even this question is making no sense.
Any clue about how to do this?
Conclusion. GraphQL allows us to make requests from our database without creating separate endpoints for each request. In this article, we built a CRUD application with Django using GraphQL queries and mutations.
Elasticsearch is a powerful search engine that can be used to power a GraphQL API. GraphQL is a query language that allows clients to request specific data from a server. When used together, these two technologies can provide a great way to access data from a large data store.
Graphene is a library that provides tools to implement a GraphQL API in Python using a code-first approach. Compare Graphene's code-first approach to building a GraphQL API with schema-first approaches like Apollo Server (JavaScript) or Ariadne (Python).
graphene is a generic GraphQL server implementation from python. Using graphene you can build a representation of your graph data and query it from anywhere (MySQL, ElasticSearch, Mongo, whatever) - each field's value is basically resolved by a resolver function which can read data from wherever needed.
graphene-django is just an extension of graphene that automatically wraps django ORM and lets you easily expose django ORM objects as part of your schema without going through the hassle of defining re-defining all the objects and fields already defined in the ORM model.
It does not, however, limit you to only use the django ORM. You can have many objects in relationships in your GraphQL schema, some objects can work against the django ORM while others can read from ElasticSearch or wherever else you store data.
I would suggest you watch this short video as an intro on how to get started writing your GraphQL server - https://www.youtube.com/watch?v=UBGzsb2UkeY Then head on to http://graphene-python.org and check out the docs.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With