All tables become queryable as root objects of GraphQL in Phrag. This is for flexible data access without being constrained to certain query structures defined in GraphQL schema. Data can be accessed at root level or as a nested object together with parent objects through relationships.
Phrag transforms a foreign key constraint into nested query objects of GraphQL as illustrated in the diagram below. This is a fundamental concept for Phrag to support multiple types of relationships:
N+1 problem is an anti-pattern where a relationship query is executed for every one of retrieved records. Phrag's query resolver implements a batched SQL query per nest level to avoid N+1 problem.
It should also be noted that Phrag does not use JOIN
for relationship queries to allow LIMIT
on nested objects.
Create
, update
and delete
mutations are created for each table. Primary keys work as an identitier of each record for mutations:
Phrag registers PK as a GraphQL object.
Create
mutation returns a PK object with generated values as a successful response.
Update
or delete
mutation requires the PK object as a parameter to identify the record for the operations.
Infinite nests: nested objects created for both origin and destination columns of foreign keys actually mean possible infinite nests, and it is possibly an attack surface when a user queries millions of nests. Phrag has a config value, max-nest-level
for this, and an error response will be returned when a query exceed the nest level specified.
Default limit: querying millions of records can be resource-intensive and we don't want it to happen accidentally. Config value of default-limit
can be used to apply default limit value when there's no limit
parameter specified in a query.
Can you improve this documentation?Edit on GitHub
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close