Web development has long been a key part of Python’s appeal. In modern web apps, rich frontends work with Python backends over REST. But even that’s getting re-examined, with recent interest in GraphQL as a query language for web data.
Want an introduction to what GraphQL means for Python? We’re fortunate to have Quazi Nafiul as the presenter for the “GraphQL in the Python World” October 31st webinar on October 31st. Quazi is known in PyCharm as the author of Mastering PyCharm, is a long-time Python web developer, and currently a software engineer at Suitsupply.
To set the scene for the webinar, we asked Quazi to join us for a quick interview.
Thanks for joining us on the webinar. Let’s jump right into GraphQL. What is one killer feature about it that you really like?
Declarative data fetching. This feature allows you to get exactly what you ask for and makes versioning much easier since one simply adds more functionality through extending a GraphQL model (very similar to a resource).
Give us a little background on yourself, your Python origin story and what you’re doing now.
My university was predominantly C++ and Java, and those languages although powerful, never felt fast to develop with for me. So, I was trying to look for something different and stumbled onto MITx’s Introduction to Computer Science, which taught the course in Python. I’ve been using Python ever since. After the MITx course, I started hanging out on StackOverflow, and realized how little I knew. I tried to expand my understanding by answering questions on the site.
In the meantime, I started doing consultancy work for companies in NY and London. I also was a developer evangelist for a short time. I wrote plenty of bad code back then. I also started writing a book on PyCharm around this period. Once the book was complete and published, and I got bored with remote work, I started applying to companies around the world and eventually ended up in Amsterdam as a software developer.
Similar question: what did you start with for Python web frameworks, what have you used, and what’s your preference now?
I started with Django, quickly moved to Flask and now I use both Django and Flask in my day job. I remember at the time Django had the most comprehensive beginner documentation you could find. I didn’t understand a lot of it when I was first starting out, so every part of the tutorial would send me down a rabbit hole. Eventually, I was able to understand how HTTP as a protocol works. Funnily enough, I thought that one always interacts with a database with an ORM, and as a result, my understanding of SQL was a little hampered in the beginning, but I eventually managed to fix that.
Just to close out on Python web frameworks, what do you think is “next big thing”?
I honestly don’t know. Python web frameworks market shares seem to be in a kind of equilibrium at the moment. Flask serves you well if you need to build something small to medium-sized, but indeed you can build huge applications with it. Django is amazing if you just want to get up and running with a CRUD application that sits on top of a regular RDBMS. I think Django will continue to have a strong presence with the resurgence of SQL and SQL databases. Pyramid is great if you need something super flexible, and you can hack to its very core, but it does not have ecosystems as strong as Flask or Django.
Back to GraphQL. What kinds of things will you be showing, and what should people expect to learn in the webinar?
My aims are twofold. The first thing is to introduce GraphQL, and really just show people how powerful it is, and how its features can bring tangible benefits to your team and allow your businesses to move forward. The second part of that is to show that you can use all the power that GraphQL brings along with the frameworks and libraries that you’re already used to, like Flask, Django, and SQLAlchemy.
Do you plan to have any working code in advance that people can review?
Yes, absolutely. I want people to be able to follow what I’m doing, and also take that code, and work on their own implementations and ideas. I’m going to be building a generic application, but I’ll do my best to showcase the most important features, so that they can take that code and start playing around on their own.
Does GraphQL mean throwing out your current database?
Nope. You don’t even have to throw out your current ORM (in most cases). If you’re using Django or SQLAlchemy, then you can just re-use your existing models! Although, it does not have the best support for Mongo or other NoSQL databases, and so you might need to build integrations with those databases.
Every “next big thing” has some rough edges. What are tricky parts for GraphQL in Python?
I would say having a standardized form of authentication. GraphQL implements a level-based authentication system (or rather you can implement it). I would say that a lot of different services that are used to HTTP REST, might not really like this, since clients don’t exist for all languages. One example would be Salesforce APEX and .NET.