Skip to content

Speedy1991/strawberry-workshop

Repository files navigation

Introduction to GraphQL and Strawberry

System Requirements

  • git v2 or greater
  • python3.11 or greater + pip (maybe a lower version will work too - please try it yourself)
  • docker for redis

This is the minimum workshop setup. Please prepare the project as described below.

Pre-Workshop Instructions/Requirements (install)

  • git clone https://github.com/Speedy1991/strawberry-workshop.git
  • cd strawberry-workshop
  • docker compose up --force-recreate --build -d
  • If you want to use a virtual environment click here for instructions
  • pip install -r requirements.txt
  • python manage.py migrate
  • python manage.py loaddata assets/data.json (Installed 206 object(s) from 1 fixture(s))
  • python asgi_server.py

Frontend

  • cd frontend
  • yarn
  • yarn build
  • yarn dev

Test your setup

  • Open your browser and visit http://127.0.0.1:8000/admin/ and try to login with root:toor
  • The GraphiQL endpoint is at http://127.0.0.1:8000/graphiql/

Exercise overview (python)

You will have about 10 min per exercise. Do not forget to reload your graphiql endpoint after you changed the schema to refelect the changes

  • Exercise 1: Write your first TypeDefs and resolvers
  • Exercise 2: Extend your TypeDefs with more complex resolvers
  • Exercise 3: Refactor
  • Exercise 4: Write a mutation; Add Field Arguments
  • Exercise 5: Interfaces
  • Exercise 6: Going Async + Dataloaders
  • Exercise 7: Subscriptions
  • Let's talk about ASGI/Starlette
  • Security & Pitfalls: Query Batching, DoS, Field Exposure, Authorization, Ratelimit, Overfetching, Underfetching, Caching, ReturnCodes, Introspection
  • Homework: Check out strawberry-django

Exercise overview (frontend)

  • Create types
  • Localcache reads and manipulations
  • Autoupdates with normalized Data
  • Query optimizations (cache redirects, cache first, etc.)
  • Push apollo to it's limits

Working through it

This is a very exercise-heavy workshop. You'll find the exercises in the strawberry_workshop/exercise[number] directory. Don't forget to change the used schema in the settings.py.

You find some helpful content on the Docs:

Helpful shortcuts

  • 🛠️ TODO: This is your job
  • 📜 DOCS: This will give you a link to the specific doc page
  • 💡 HINT: This will give you some useful tips
  • QUESTION: Try to answer the question yourself - if you don't find the answer, feel free to ask :)

Django Cheatsheet

  • SELECT * FROM <table> -> <ModelName>.objects.all()
  • SELECT * FROM <table> WHERE id=<id> -> <ModelName>.objects.get(id=id) (raises if not exist)

Database overview

Database overview

Strawberry

Docs: https://strawberry.rocks/

Discord: https://strawberry.rocks/discord (be friendly, this is an awesome community)

Github: https://github.com/strawberry-graphql/strawberry

Creator: Patrick Thank you so much for creating this awesome framework

Core Devs: bellini666, DoctorJohn, erikwrede, skilkis

In this context, we should generally express our gratitude to all open-source developers and contributors.

License

This material is available for private, non-commercial use under the GPL version 3.

If you would like to use this material to conduct your own workshop, please contact me at [email protected]

Closing

If you enjoyed the workshop, Patrick would surely appreciate a small sponsorship to support his open-source work going forward.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published