
Explore GraphQL, a data query language that lets clients request exactly what they need in a single request, improving efficiency over REST. Embrace strong typing, self-documenting APIs, and change management.
Explore GraphQL queries using an in-browser IDE to visualize schema structure and test requests. Get familiar with Python-based GraphQL syntax, including fields, arguments, fragments, variables, and directives.
Explore how GraphQL lets clients specify the exact data they want, using queries in GraphQL, validated by a server schema, and returned in the requested shape with live examples.
Explore GraphiQL features like predefined queries, fragment merging, copy query, multiple queries with tabs, variables and headers, plus docs and history to refresh schema and troubleshoot fields.
Learn how a selection set represents the top-level object and its nested attributes as a GraphQL shorthand, and how explicit operation type, name, and variables yield an identical query.
Explore how arguments power GraphQL queries by filtering, paginating, and randomizing results with skip, limit, and a random boolean argument, then filter by team and season to refine data.
Learn how to parameterize GraphQL queries with variables using dollar signs, types, and a separate variables JSON, enabling runtime substitution for options like team, season, and limit.
Define reusable GraphQL fragments with the fragment keyword on a type, then use the ellipsis to spread them in queries, enabling modular, readable player info and performance fields.
Leverage GraphQL directives to conditionally include or skip fields using built-in skip and include, driven by boolean variables, and extend with custom directives for authentication and other behaviors.
Practice building a GraphQL query that selects ten random players from a season with height under a threshold, using variables and a fragment for name, height, team, and drafted year.
Define a GraphQL query with height and season variables to fetch ten players shorter than a threshold, returning name, height, team abbreviation, and draft year. Refactor as a fragment.
Define and build your first GraphQL server in Python, compare code-first and schema-first approaches, and use an in-memory list in a single Python script for learning GraphQL concepts.
Explore schema-first versus code-first design for GraphQL, weighing collaboration and maintenance; the course uses a code-first Python approach with graphene, inferring the schema from code.
Explore code-first GraphQL API design using graphene in Python, comparing strawberry and graphene, defining schemas, object types, fields, resolvers, arguments, and mutations.
Set up a Python virtual environment in your project directory, activate it across platforms, and install graphene 3.2 to create a sandbox that keeps dependencies isolated.
Build and test a hello world GraphQL application programming interface in Python using graphene, defining a schema, a query class, a resolver, and executing a query with optional name arguments.
Define a user type with id, name, and age and wire a resolver to query by user id using a dummy data store, illustrating GraphQL data retrieval in Python.
Explore how GraphQL root values shape the execution context and how PyCharm flags a method as static, clarifying the difference between self, route value, and data source in a query.
Define a list-type field in graphene to return all users above a minimum age, and implement a resolver that filters by age, illustrating GraphQL naming with snake_case versus camelCase.
Define and wire GraphQL mutations to modify data in a Python data store, implementing a create user mutation with name and age, and connecting it to the schema.
Clarify odd-looking GraphQL mutation concepts by explaining why we return a create user mutation instance, how the dot field configures resolvers, and how schemas expose the created user fields.
Implement a GraphQL update user mutation to modify a user's name or age by id, including required user id and optional name or age, and test with queries.
Implement a delete user by ID mutation in GraphQL using Python, taking a user ID and removing that user from the data store, building on the create and update mutations.
Implement a delete user mutation by id in a python graphql API, using enumerate to locate and remove the user from the list, returning the user or none.
Define the GraphQL server, create a new web API with FastAPI, enable the graphical interface, and outline basic GraphQL operations as foundational for the course.
Create and activate a new Python virtual environment in the GCL App directory, install graphene, Fast API, Starlet graphene, and uvicorn, then freeze dependencies into a requirements.txt.
Build a bare bones GraphQL API with graphene, mount it on a fastapi app, and run with uvicorn to expose /graphql, then note GraphQL uses POST and GET is rejected.
Test a GraphQL API using an HTTP client by sending a POST request to localhost:8000/graphql with a GraphQL body and hello query. Verify server works and note playground setup next.
Add a graphical interface to a fast API GraphQL app using Starlight Graphene to mount a graphical or playground handler that exposes an in-browser, post-request driven UI at the endpoint.
Develop a GraphQL API for a job board by defining employer and job entities, linking them with bidirectional references, and deferring type evaluation with lambdas to avoid circular dependencies.
Define a first query class with jobs and employers, add temporary data, and implement resolvers to fetch both entities. Test in the playground and prepare to tackle cross-link resolution next.
Learn how field-level resolvers link nested jobs and employers in GraphQL with Python, using root resolvers and concise generator-based resolution. Test in the GraphQL playground and preview SQLAlchemy ORM integration.
Explore how to connect databases to a web API and GraphQL server using Postgres on the cloud with SQLAlchemy ORM in Python.
Install and configure SQLAlchemy for Python, leveraging its core and ORM APIs to write dialect-agnostic queries, then connect to PostgreSQL using psycopg2 or the binary driver.
Choose the database type and Postgres dialect that fit your data, then set up a free cloud Postgres on bit.io with JSON B support and note the connection string.
Explore how SQLAlchemy creates an engine from a database URL, uses a connection pool, and obtains connections via engine.connect to execute queries.
Define an employer model with SQLAlchemy's declarative base, map it to the employers table, and create the table via metadata.create_all, then verify the table exists in the database.
Define a jobs table with a foreign key to employers and establish a bidirectional relationship using the SQLAlchemy ORM, via relationship and back_populates, linking employers and jobs.
Use SQLAlchemy ORM sessions to seed employer and job data by creating instances, adding to session, and committing; leverage dictionary unpacking to streamline the process, and verify results in be.io.
Recreate the database schema at startup to avoid duplicate inserts by dropping and recreating tables, seeding data via a startup event in FastAPI.
Refactor your GraphQL API project for clear separation of concerns by organizing code into app, GraphQL types, database models, and config packages, preventing name collisions and easing debugging.
Learn to reorganize a Python GraphQL API into packages, separating Graphene types and queries, and wiring SQLAlchemy models, a config-driven engine, and dummy data for scalable development.
Run the app with uvicorn, then retrieve data using session.query to fetch all employers and jobs, test the endpoints, and prepare for GraphQL API integration.
Refactor the route and field level resolvers in the GraphQL API to fetch data from the database, ensuring root and nested fields are fully resolved.
Implement root and field level resolvers for a GraphQL API with SQLAlchemy, fetch records via a session, and enable eager loading with joinedload to resolve related employers and jobs.
Explore implementing core CRUD operations on job and employer entities with SQLAlchemy and Graphene, introducing users and job applications, and preparing authentication and authorization for a GraphQL API.
Create a GraphQL mutation to add jobs in a FastAPI app, using graphene, a SQLAlchemy session, and auto-incremented Postgres IDs to insert and refresh new job records.
Update an existing job with a GraphQL mutation in a Python API, validate the job id, apply optional field updates via SQLAlchemy, and load related employer data eagerly.
Configure the ORM to enable a global joined load by setting the relationships' lazy parameter to joined, ensuring related employer and job data load with every query.
Add a GraphQL job field by ID and implement a resolver to fetch the corresponding job from the database, with joined related entities loaded by default.
Implement a delete job mutation in GraphQL with SQLAlchemy that accepts a job ID, deletes the matching job, commits the change, and returns a boolean success indicator.
Implement the create mutation for the employer entity in a Python GraphQL API using SQLAlchemy to instantiate, persist, and return the new employer with its generated id.
refactor a growing GraphQL API in Python by organizing mutations and queries by entity, introducing a job package with its mutations, and progressively tidying imports, types, and resolvers.
Learn to query a single employer by id in a GraphQL API. Return only the requested fields such as id, contact, and email, with an optional fragment.
Learn to extend a Python GraphQL API by adding a single employer query and resolver using SQLAlchemy, and use fragments to fetch employer and related job fields by ID.
Implement a GraphQL mutation to update an employer by id, allowing optional updates to name, location, and other fields while keeping the id immutable.
Implements a GraphQL update employer mutation in Python, using SQLAlchemy to fetch, conditionally update optional fields, commit, refresh, and return the updated employer object.
Delete an employer by ID via a GraphQL mutation in a Python-based API. Return a success boolean to indicate operation results.
Implement a delete employer mutation by validating the employer exists, deleting via a session, committing changes, and returning a success boolean.
Define a new user entity with id, username, email, and role in the database. Map to a Graphene user type that omits password and add a query returning all users.
Take on an end-to-end challenge: add a new job application entity with foreign keys to user and job, and expose related user and job data via GraphQL.
Define a job applications database model with foreign keys to users and jobs, establish two-way relationships, and implement Graphene types, queries, and resolvers to test in the playground.
Enable two-way querying between users, jobs, and applications by updating graphene schemas and resolvers, then compose nested queries that traverse related entities to reduce over-fetching with GraphQL.
Wrap up the job board app by learning authentication and authorization, implementing workflows, and integrating them with a GraphQL API, while exploring decorators for authorization utilities through practical challenges.
Clarify the difference between authentication and authorization, showing how authentication verifies identity while authorization grants permissions using RBAC or ABAC in web apps.
Build a login mutation to authenticate seeded users by email and password, returning a temporary token tested in the GraphQL playground.
Understand password hashing, where plaintext passwords become hashes via a cryptographic hash function, protected by salts and Argon2 to thwart rainbow and dictionary attacks in web apps.
Integrate Argon2 password hashing in the database and GraphQL API by updating the user model to password_hash, hashing seed passwords before insert, and verifying hashes in login mutations with salting.
Generate a JWT after login to encode the user id and timestamp in a header and payload via base64, with a signature, then send the token in the authorization header.
Generate JSON web tokens on user login using PyJWT in a GraphQL login mutation, encoding the user email with a 15-minute expiration and SHA-256, with secret keys moved to config.
Refactor the codebase by moving shared utilities to a new utils.py, separating password hashing and verification from GraphQL logic, and integrating token generation for cleaner, reusable components.
Implement bearer token authentication for a GraphQL server by decoding JWTs from the authorization header, validating expiration, loading the authenticated user, and integrating the get_authenticated_user helper with add employer mutation.
Address circular import issues by relocating the session import into the prepared database helper, linked to the get authenticated user implementation, and discuss refactoring to expose a get session method.
Implement the add user mutation in GraphQL to register users, enforce unique emails by raising an exception on duplicates, and apply a straightforward create mutation as in the previous section.
Implement a GraphQL add user mutation that accepts username, email, password, and role, hashes the password, checks for existing email, and returns the new user (id, username, email, role).
Tackle a new challenge to enforce administrator privileges in the add user mutation by requiring an existing admin to log in and authorize admin creation, while preserving non-admin registration flows.
Implement admin check in add user mutation to ensure only admins can create admin users, validating the current user with the JWT.
Learn to implement an admin_user decorator to enforce admin-only access in GraphQL mutations by wrapping mutation functions and preserving metadata with functools.wraps.
Implement an admin-only decorator for all job and employer mutations to restrict add, update, and delete actions to administrators, reducing repeated code and centralizing authorization logic.
Define an ApplyToJob mutation in GraphQL that requires an existing user and job and prevents duplicate applications by the same user.
Define an apply-to-job mutation in SQLAlchemy that takes user_id and job_id, validates no existing application, creates and saves a new job_application, and returns the job_application instance.
Learn to create a decorator that enforces authentication for GraphQL mutations in Python, reuse the get authenticated user helper, and apply it to the apply to jobs mutation.
Define a decorator that enforces user authentication using the get authenticated user helper function, then apply it to the apply to job mutation to require a valid token.
Enforce that the apply-to-job mutation only succeeds when the authenticated user matches the user ID in the JWT, preventing unauthorized cross-user applications.
Enforce auth by comparing the authenticated user's id from the json web token with the user_id in the apply to job mutation, using a decorator to prevent impersonation.
Generalize JSON web token errors into missing authentication token or invalid authentication token, consolidating bearer and header issues while masking details in production.
Learn to deploy your GraphQL Python API to the web, beyond localhost, and master Git, GitHub, Vercel, and the deployment workflow.
Explore deployment options for Python-based GraphQL APIs, comparing cloud providers and Docker on Cloud Run, and learn to deploy with Vercel via a GitHub workflow enabling zero-cost serverless, continuous deployment.
Refactor the app to use environment variables via a .env file and dotenv, aligning with the 12-factor app, with os.getenv for secret key, algorithm, token expiration, and database URL.
A quick bug fix resolves an invalid authentication token error caused by a refactor; jwt decode expects bytes, so selecting the second token after split restores a valid bearer token.
Move main.py to the root, route the app to the root endpoint, redirect GraphQL to the playground, and switch to psycopg2 binary for Vercel deployment.
Configure a git ignore to exclude the virtual environment, dot env files, and IDE caches for clean deployments. Create vercel.json with a simple build and route all requests to main.py.
Initialize the repository with git init, stage changes with git add ., review with git status, and commit with git commit -m 'initial commit' to create project snapshots.
Push your local repository to GitHub so Vercel can build and deploy automatically, using a remote origin, renaming to main, and pushing with upstream.
Deploys a Python-based GraphQL API to vercel, configures vercel.json and environment variables, uses seed data, and runs as a serverless function with a JWT token.
Demonstrate end-to-end workflow: add a new http endpoint to count job applications using SQLAlchemy, commit and push to main, triggering automatic deployment on Vercel, then verify with authenticated queries.
Conclude this course on building GraphQL APIs with Python by thanking learners and inviting them to explore discounted courses on andy.com and handbag.com, including pandas, SQL, and web scraping.
Explore Python data types and how they determine memory storage and operations, including integers, floats, booleans, strings, tuples, lists, sets, dictionaries, and None, with the type function and print.
Learn variables in Python: bind values to names, use descriptive identifiers, follow snake_case, respect case sensitivity and keywords, and perform multiple assignments to build readable, maintainable code.
Learn basic and augmented arithmetic operators in Python, including addition, subtraction, multiplication, division, and modulo; apply augmented assignment like counter plus equals one, and understand operator precedence (pemdas).
Explains integers and floats in Python, how division creates floats, how to convert with int() and float(), and the binary representation caveats affecting precision.
Explore booleans as true or false in Python. Use operators like >, <, >=, <=, ==, != and distinguish assignment from equality; then combine booleans with and, or, not.
Explore Python strings as ordered sequences of characters, including letters and punctuation. Learn to use single or double quotes, escape characters, triple quotes for multi-line strings, and concatenation and repetition.
Explore how methods attach to objects and differ from functions, examine string methods like upper, lower, is alpha, starts with, ends with, and the format method for substitutions with placeholders.
Master Python lists as ordered containers created with square brackets, using zero-based indexing, slicing, and negative indexing, including how to access elements and handle index errors.
Explore how lists and strings work as Python sequences: both are ordered and indexable, but lists are mutable while strings are immutable.
Learn to manipulate Python lists with built-in functions like max, min, len, and sorted, and list methods such as append, pop, remove, and join to form strings.
Explore Python tuples as immutable, ordered containers; create them with optional parentheses, index elements, and see why they pair related values, such as SAT scores or coordinates.
Learn how Python sets are unordered containers of unique values, created with curly braces, how duplicates are dropped when converting lists, and how union, intersection, and difference operators compare sets.
Learn how Python dictionaries store key-value pairs with curly braces, access values using brackets or get, handle missing keys gracefully, and add or remove entries with assignment and pop.
Explore dictionary keys and values, where keys are immutable (strings or tuples) and values can be any type, including lists or nested dictionaries, and use methods dict_keys, dict_values, and dict_items.
Master Python membership tests using the in and not in operators across dictionaries, lists, tuples, and sets, with hands-on true/false examples and notes on string storage in list-like structures.
Learn to control program flow in Python with if, elif, and else to decide pass or fail based on exam scores and attendance, using booleans and proper indentation.
Explore Python truth values for non-booleans, where most objects are true and None, false, and empty collections are falsy; see how if statements rely on truthiness rather than explicit comparisons.
Learn how to use Python for loops to iterate over iterables, assign meaningful iteration variables, and execute a block of code for each item, including strings and lists.
The range function defines an immutable sequence of integers with start inclusive and stop exclusive, and step. A single argument is treated as stop, with start 0 and step 1.
Explore while loops in python: run until a condition fails, using a condition and loop body. A doubling-cost example shows updating balance and next round cost to prevent infinite loops.
Learn how break interrupts loops to stop execution and how continue skips an iteration in Python, demonstrated with greetings in for and while loops.
Explore how Python's zip combines multiple iterables into paired tuples and how to unpack and iterate over names, scores, and attendance data for building GraphQL APIs.
Explore Python list comprehensions to filter and transform data in a single elegant line. Practice selecting odd numbers, squaring values, and extracting high-scoring student names without explicit loops.
Define Python functions with def, including get average, to compute averages, then iterate over students to add average and past keys.
Explore positional versus keyword arguments in Python with a reverse name function that outputs last, comma, space, then the first name. Learn why keyword before positional raises a syntax error.
Explore lambda functions in Python—anonymous, inline one-liners used for simple tasks and with map for functional programming; learn their syntax, usage, and how they map to future pandas operations.
Explore importing modules in the Python standard library, using from statistics import mean, and aliasing pandas as pd and matplotlib as plt to avoid reinventing the wheel.
Welcome to the best resource online for learning GraphQL with Python!
In this course you will learn how to build GraphQL APIs to replace standard REST APIs and their limitations. In addition, you will learn about features like authentication, object-relational mapping, version control, and deployment, which go hand in hand with modern application development of GraphQL APIs.
Today GraphQL is used by teams of all sizes in many different environments and languages to power mobile apps, websites, and APIs. From Airbnb and Atlassian to Audi and GitHub, companies the world over are using GraphQL APIs in production. GraphQL has gained significant traction in recent years because it offers a more flexible and efficient approach to data retrieval that addresses over-fetching and under-fetching issues that are common with REST APIs.
This course is for anyone looking to learn GraphQL with Python. It is designed to teach you everything you need to know to build production-ready GraphQL APIs with Python.
In the first 2 hours you will learn the basics of GraphQL, how to build a GraphQL server with Python, and how to expose a web API to interact with it.
This introduction will give you a solid foundation of the core GraphQL concepts like schemas, types, queries, mutations, variables, fragments, directives and more. We will be working with a live GraphQL API, as we explore these concepts through a graphical in-browser IDE, constructing queries and mutations, and exploring result sets in real time.
In the second part of the course we'll delve into more advanced topics, as we integrate our GraphQL applications with cloud-hosted SQL databases, and in the process also gain a practical understanding of the widely-popular SQLAlchemy ORM. We'll define advanced mutations and query capabilities, before we shift our attention to authentication and authorization flows, where we will use JSON web tokens to implement a role-based permissioning system. In the end we will deploy our application as a serverless function to the cloud, for free.
Throughout the course you’ll learn how to:
Model your application data using schemas and entities
Create queries allowing clients to access data in the database through GraphQL
Create mutations allowing clients to create and change data in the database
Query and change your data from the browser by making requests with graphical, in-browser IDEs
Work with the SQLAlchemy ORM (v2) to communicate with your database
Secure your application data with JWT-based authentication and authorization system
Deploy your GraphQL applications as serverless functions, for free
This course assumes you're somewhat familiar with python, but if you're not or haven't programmed in python for a while, there is a full length introduction to the python programming language included as an appendix.
I'm excited to be your instructor. See you inside!