CentreForDigitalHumanities / lettercraft

Lettercraft & Epistolary Performance in Medieval Europe
BSD 3-Clause "New" or "Revised" License
1 stars 0 forks source link

Feature/graphql scaffold #81

Closed XanderVertegaal closed 1 week ago

XanderVertegaal commented 3 weeks ago

Part of #75

Basic implementation of a GraphQL API using Graphene (Django) en Apollo (Angular).

Don't forget to install dependencies and run yarn codegen when running the application frontend.

This PR also adds a SourceType, a query sources and two mutations: DeleteSource and UpdateOrCreateSource, so there is something to test. Visit localhost:8000/api/graphql to test them out.

Still to do (in other PRs):

I'll focus on writing more types and queries after this PR so we can start using them in the frontend when the views/components are there.

XanderVertegaal commented 2 weeks ago

To address the main issue of authentication: you're right that the endpoint used to be reachable for everyone. To address this, I've added a simple Middleware (only for requests aimed at the GraphQL endpoint) that check if the user is authenticated or not. You can test this by visiting localhost:8000/api/graphql and querying sources both when you're logged out and when you're logged in. I've also added a test to makes sure this doesn't break. (Run with python manage.py test)