Skip to content

Minor bug fixes and enhancements - #1

Merged
dylanmcreynolds merged 11 commits into
als-computing:graphfrom
genematx:graph-eugene
Aug 5, 2026
Merged

Minor bug fixes and enhancements#1
dylanmcreynolds merged 11 commits into
als-computing:graphfrom
genematx:graph-eugene

Conversation

@genematx

@genematx genematx commented Aug 3, 2026

Copy link
Copy Markdown

Bug fixes

  • share/tiled/templates/index.html — corrected the landing-page GraphQL link from /graphql to /api/graphql (matches the actual mount point).
  • tiled/catalog/migrations/versions/c31f6a1d7e20_..._tables.py — migration now also creates and drops the namespaces table (previously only entities and links), so existing databases get the full graph schema on upgrade.

Schema provisioning refactor

  • tiled/graph/tables.py (new) — declares entities, links, and namespaces as Core tables on the catalog's Base.metadata.
  • tiled/catalog/core.py — initialize_database imports the graph tables so fresh databases create them via create_all (existing databases get them via the migration).
  • tiled/graph/store.py — no longer creates its own schema at runtime; consumes the shared table objects and reuses the catalog nodes table for node-id resolution. Removed the private _metadata/_nodes stubs and _initialize_schema.
  • tiled/graph/core.py (deleted) — dead, unreferenced module carrying a stale revision id.

GraphiQL UX

  • tiled/graph/router.py — _TiledGraphQLRouter preloads a graph-specific default query (with API-key header guidance) instead of Strawberry's generic welcome text; falls back to the stock page if the template marker ever changes.

Declare the entities, links, and namespaces tables on the catalog
Base.metadata so fresh databases create them via initialize_database,
matching the migration used for existing databases. The graph store no
longer creates its own schema at runtime and reuses the catalog nodes
table for node id resolution.
Use the interactive <em>GraphQL</em> playground to query the links graph.
</h2>
<a href="{{ root_url }}/graphql" target="_blank" rel="noreferrer">
<a href="{{ root_url }}/api/graphql" target="_blank" rel="noreferrer">

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On second thought...since we're marking this new feature as experimental, do we even want to link to it from the tiled landing page?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can leave it out for now -- easy to add later. @danielballan, what do you think?

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure. I'm good either wya.

Comment thread tiled/catalog/core.py Outdated

@dylanmcreynolds dylanmcreynolds left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great, thank you for this PR!

These are great changes. I have added a couple of questions before merging.

Match the catalog's naming convention (tiled.catalog.orm), where SQLAlchemy
table definitions on Base.metadata live in an orm module. No behavior change.
The entity/link graph is recursively traversable (Entity.outgoingLinks ->
Link.object -> Entity.outgoingLinks -> ...), so an unbounded nested query
could force arbitrarily deep and expensive resolution. Add a QueryDepthLimiter
(max depth 10) to the schema. Introspection queries are exempt, so the
GraphiQL Docs panel is unaffected.
…ecks

create_link previously issued two SELECTs to confirm the subject and object
entities exist before inserting, duplicating work the schema layer already
does and leaving a window between the checks and the insert. Insert directly
and rely on the subject_id/object_id foreign keys (SQLite enforces these too,
via the shared pool's PRAGMA foreign_keys=ON). Only on a constraint violation
does it look up which endpoint is missing, so the success path is a single
atomic INSERT while error messages are unchanged.
@genematx

genematx commented Aug 5, 2026

Copy link
Copy Markdown
Author

I've also added a limit on recursive queries and made inserting a link reliant on DB-level integrity constraints. Overall, I think it's ready; we can add anything else in future PRs. Thank you, Dylan!

@dylanmcreynolds
dylanmcreynolds merged commit 8fc0922 into als-computing:graph Aug 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants