-
-
Notifications
You must be signed in to change notification settings - Fork 32
Add mapping concepts and query pipeline documentation #930
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,5 +2,7 @@ laika.navigationOrder = [ | |
| index.md | ||
| tutorial | ||
| howto | ||
| mappings.md | ||
| pipeline.md | ||
| CONTRIBUTING.md | ||
| ] | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -26,6 +26,10 @@ in the `Elab` monad. `Elab` gives phases access to the schema, the current conte | |
| definitions, and allows compilation to be aborted with one or more GraphQL errors via `Elab.failure`. A phase which | ||
| fails prevents the query from executing at all — the client receives an error response with no data. | ||
|
|
||
| `transform` is not abstract: the inherited implementation walks the whole query algebra, maintaining the `Elab` | ||
| context as it descends, so a phase overrides it for the node types it cares about and delegates the rest to | ||
| `super.transform`. | ||
|
|
||
| This makes phases a natural place to enforce global policies on incoming queries. Grackle provides one such policy | ||
| phase out of the box: `QuerySizeValidator`. | ||
|
|
||
|
|
@@ -45,7 +49,7 @@ _Depth_ is the number of nested selection levels in the query, and _width_ is th | |
| selected. Both are computed after fragment spreads have been resolved, so a query cannot evade the limits by | ||
| factoring its selections into fragments. | ||
|
|
||
| For example, with the Star Wars model from the previous chapter and the limits above, the query, | ||
| For example, with the [Star Wars model](../tutorial/in-memory-model.md) and the limits above, the query, | ||
|
|
||
| ```yaml | ||
| query { | ||
|
|
@@ -84,8 +88,11 @@ exceeding both limits at once is reported as `"Query is too complex"`. | |
|
|
||
| ## Limitations | ||
|
|
||
| Depth and width are syntactic measures: they are computed from the query text alone and know nothing about the size | ||
| Depth and width are structural measures: they are computed from the query's shape and know nothing about the size | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not convinced this is an improvement. The key contrast is between the query text, which is syntax, and data-independent, and the result size, which is data dependent. |
||
| of the underlying data. In particular, width does not account for list sizes — a field yielding a thousand elements | ||
| contributes to the width just once. `QuerySizeValidator` is therefore a coarse first line of defence rather than a | ||
| complete cost model. Guarding against expensive list expansions requires taking field cardinalities and arguments | ||
| into account, which can be implemented as a custom phase following the same pattern. | ||
|
|
||
| Introspection is not measured at all: an `Introspect` node contributes nothing to either figure, so a deeply | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not to say that this is inaccurate, but it might actually be a problem 🤔 |
||
| nested `__schema` query passes whichever limits are configured. | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,5 @@ | ||
| laika.title = How-to Guides | ||
| laika.navigationOrder = [ | ||
| interfaces-across-tables.md | ||
| compiler-phases.md | ||
| ] |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -30,6 +30,9 @@ and [imbus AG](https://www.imbus.de/) over the last five years. | |
| ## Getting Started | ||
|
|
||
| - See the [tutorial](https://typelevel.org/grackle) and accompanying [demo](https://github.com/typelevel/grackle/tree/main/demo/src/main). | ||
| - New to Grackle's mapping model? Start with [Mapping Concepts](https://typelevel.org/grackle/mappings.html) for a guided tour of | ||
| `ValueMapping`, `GenericMapping`, `CirceMapping`, `SqlMapping`, `ComposedMapping` and friends, | ||
| and how to pick the right one for your data source. | ||
| - Online Scaladoc is available [here](https://javadoc.io/doc/org.typelevel/grackle-core_2.13). | ||
| - Ask us anything the in **#grackle** channel on the Typelevel [discord server][grackle-dev]. | ||
|
|
||
|
|
@@ -56,6 +59,12 @@ libraryDependencies += "org.typelevel" %% "grackle-doobie-oracle" % "@VERSION@" | |
|
|
||
| // Optional: support for SQL Server backend via Doobie (JVM only) | ||
| libraryDependencies += "org.typelevel" %% "grackle-doobie-mssql" % "@VERSION@" | ||
|
|
||
| // Optional: support for H2 backend via Doobie (JVM only) | ||
| libraryDependencies += "org.typelevel" %% "grackle-doobie-h2" % "@VERSION@" | ||
|
|
||
| // Optional: support for SQLite backend via Doobie (JVM only) | ||
| libraryDependencies += "org.typelevel" %% "grackle-doobie-sqlite" % "@VERSION@" | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. More to add now 😄 |
||
| ``` | ||
|
|
||
| ## Running tests for database backed mappings | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
MOAR!!!