Sketch is a GraphQL API to draw on a canva.
The core functionalities of drawing on a canvas are implemented in canvas.ex.
The GraphQL schema, with its queries, mutations and subscriptions is to be found in schema.ex.
You can talk to the server either with the GraphiQL client (for reads and writes) or the browser (read-only client). LiveView is used to avoid browser refreshes and update the web page with the new canvas/drawing in real-time.
To play around, follow those instructions:
- Install dependencies with
mix deps.get - Create and migrate your database with
mix ecto.setup - Start Phoenix endpoint with
mix phx.serveror inside IEx withiex -S mix phx.server - Now you can visit localhost:4000/canvas from your browser.
- In a new window, visit the GraphiQL endpoint.
- Upload the GraphiQL workspace (note: you might need to refresh GraphiQL or select a query from the workspace history).
- You'll find three tabs with pre-made queries in each. Each sequence of queries in a tab corresponds to a test fixture. Give it a try!
- On localhost:4000/canvas, you'll find the web page that displays all the canvas unique global identifiers. If a new canvas is added, its id will appear here automatically, without you having to refresh the web page.
- If you want to see a specific canvas and how it changes as it is updated, simply click on its id.
mix test --trace