- GraphQL API for Sets, Entries, Metadata, Previews (e.g. enough data for a Lightbox gallery)
- read-only data (only
query
, nomutation
) - only public data (no auth, no access control except the
get_*
fields) - no hard dependencies on other parts of Madek except read-only access
- (local development environment shares some code like DB migrations)
- fully tested with RSpec (maybe turnip?)
- test data in db + query + variables => expect result
- schema, incl. backwards compat tracking
- perf testing? (relative query runtime?)
- performance: should be fast enough to render gallery of 100 photos in set server-side and retain reasonable loading time
- efficient batching / pagination
- (SQL) query optimization
- basic "evil" query protection (maximum depth, timeouts)
reading material:
- https://graphql.org/learn/
- https://madek.readthedocs.io/en/latest/architecture/entities/#public-resources
- https://graphql-ruby.org
- https://www.youtube.com/watch?v=Wlu_PWCjc6Y (advanced)
- https://github.com/chentsulin/awesome-graphql (more resources)
install
git clone https://github.com/Madek/madek-graphql-api && cd madek-graphql-api
git submodule update --recursive --init --force
./scripts/bundle
initial config
cd datalayer
cp config/database_developer_example.yml config/database.yml
# edit config/database.yml
cd -
reset db && startup
./scripts/dev-reset
PORT=4321 ./scripts/start-dev-server
helpers
query {
mediaEntry(id: "06622f9c-8f41-43eb-a4a4-fd3b8444de64") {
id
createdAt
title
}
}
=>
{
"data": {
"mediaEntry": {
"id": "06622f9c-8f41-43eb-a4a4-fd3b8444de64",
"createdAt": "2012-10-16 13:57:54 UTC",
"title": "Diplom"
}
}
}