From 89923796d2acb85bea5eb02a54190e75aa0ccc8f Mon Sep 17 00:00:00 2001 From: Orpheus Lummis Date: Sat, 13 May 2023 05:40:10 -0500 Subject: [PATCH] fix: Resolving multiple issues: casing, some incorrect GraphQL queries, details (#122) --- docs/guides/explain-systems.md | 15 ++-- docs/guides/schema-relationship.md | 68 +++++++++---------- docs/guides/time-traveling-queries.md | 6 +- docs/intro.md | 2 +- .../aggregate-functions.md | 8 +-- .../references/query-specification/aliases.md | 8 +-- .../query-specification/database-api.md | 4 +- .../query-specification/filtering.md | 24 +++---- .../query-specification/grouping.md | 12 ++-- .../limiting-and-pagination.md | 4 +- .../query-specification/mutation-block.md | 19 +++--- .../query-specification/relationships.md | 16 ++--- .../sorting-and-ordering.md | 32 ++++----- .../query-specification/variables.md | 6 +- 14 files changed, 115 insertions(+), 109 deletions(-) diff --git a/docs/guides/explain-systems.md b/docs/guides/explain-systems.md index 81a746c..07b07d2 100644 --- a/docs/guides/explain-systems.md +++ b/docs/guides/explain-systems.md @@ -12,7 +12,7 @@ The DefraDB Explain System is a powerful tool designed to introspect requests, e ```graphql query { - author { + Author { _key name age @@ -24,7 +24,7 @@ query { ```graphql query @explain { - author { + Author { _key name age @@ -78,11 +78,14 @@ Simple Explain Requests is the default mode for explanation, only requiring the This mode of explanation returns only the syntactic and structural information of the Plan Graph, its nodes, and their attributes. -The following example shows a Simple Explain request applies to an `author` query request. +The following example shows a Simple Explain request applies to an `Author` query request. ```graphql query @explain { - author {nameage} + Author { + name + age + } } ``` @@ -96,7 +99,7 @@ query @explain { "scanNode": { "filter":null, "collectionID": "3", - "collectionName": "author", + "collectionName": "Author", "spans": [{ "start": "/3", "end": "/4" @@ -122,7 +125,7 @@ The following example shows a Execute Explain request applies to an author query ```graphql query @explain(type: execute) { - author { + Author { name age } diff --git a/docs/guides/schema-relationship.md b/docs/guides/schema-relationship.md index 5267774..f59dabe 100644 --- a/docs/guides/schema-relationship.md +++ b/docs/guides/schema-relationship.md @@ -52,18 +52,18 @@ The following pointers provide a concrete guide on how to implement various defi Once these schemas are loaded into the database, it will automatically create the necessary foreign keys in the respective types. ```graphql -type user { +type User { name: String username: String age: Int - address: address @primary + address: Address @primary } -type address { +type Address { streetNumber: String streetName: String country: String - user: user + user: User } ``` @@ -73,7 +73,7 @@ type address { ```graphql mutation { - create_address(data: "{\"streetNumber\": \"123\", \"streetName\": \"Test road\", \"country\": \"Canada\"}") { + create_Address(data: "{\"streetNumber\": \"123\", \"streetName\": \"Test road\", \"country\": \"Canada\"}") { _key } } @@ -81,23 +81,23 @@ mutation { ```graphql mutation { - create_user(data: "{\"name\": \"Alice\", \"username\": \"awesomealice\", \"age\": 35, \"address_id\": \"bae-fd541c25-229e-5280-b44b-e5c2af3e374d\"}") { + create_User(data: "{\"name\": \"Alice\", \"username\": \"awesomealice\", \"age\": 35, \"address_id\": \"bae-fd541c25-229e-5280-b44b-e5c2af3e374d\"}") { _key } } ``` -Note: Currently, the developer must create the secondary side of the relation (address) first followed by the primary side with the secondary id (address_id) included, but in a future version of Defra, this can be done in either order. +Note: Currently, the developer must create the secondary side of the relation (`Address`) first followed by the primary side with the secondary id (`address_id`) included, but in a future version of Defra, this can be done in either order. 3. Querying Types - After creating the required documents, the developer has to send a query request from the primary side. Therefore, in the above example, it will ask for the three respective fields of the "user", and it will also have the embedded address type in the selection set. As the developer will query from the "user" into the "address", and as defined above, the "user" is the primary type, this lookup of "user" into "address" will be an efficient lookup that will only require a single point. A single point lookup means that it won't incur a table scan. This is explained in the query below: ```graphql query { - user { + User { name username age - address { + Address { streetNumber streetName country @@ -109,11 +109,11 @@ query { ```graphql query { - address { + Address { streetNumber streetName country - user { + User { name username age @@ -125,11 +125,11 @@ query { ```graphql query { - user (filter: {address: {country: "Canada"}}) { + User (filter: {Address: {country: "Canada"}}) { name username age - address { + Address { streetNumber streetName country @@ -151,17 +151,17 @@ Note: Defra supports queries from both sides, regardless of which side is the pr ```graphql # schema.graphql -type author { +type Author { name: String dateOfBirth: DateTime - authoredBooks: [book] + authoredBooks: [Book] } -type book { +type Book { name: String description: String genre: String - author: author + author: Author } ``` @@ -177,7 +177,7 @@ defradb client schema add -f schema.graphql ```graphql mutation { - create_author(data: "{\"name\": \"Saadi\",\"dateOfBirth\": \"1210-07-23T03:46:56.647Z\"}") { + create_Author(data: "{\"name\": \"Saadi\",\"dateOfBirth\": \"1210-07-23T03:46:56.647Z\"}") { _key } } @@ -186,7 +186,7 @@ mutation { ```graphql mutation { - create_book(data: "{\"name\": \"Gulistan\",\"genre\": \"Poetry\", \"author_id\": \"bae-0e7c3bb5-4917-5d98-9fcf-b9db369ea6e4\"}") { + create_Book(data: "{\"name\": \"Gulistan\",\"genre\": \"Poetry\", \"author_id\": \"bae-0e7c3bb5-4917-5d98-9fcf-b9db369ea6e4\"}") { _key } } @@ -195,7 +195,7 @@ mutation { ```graphql mutation { - update_author(id: "bae-0e7c3bb5-4917-5d98-9fcf-b9db369ea6e4", data: "{\"name\": \"Saadi Shirazi\"}") { + update_Author(id: "bae-0e7c3bb5-4917-5d98-9fcf-b9db369ea6e4", data: "{\"name\": \"Saadi Shirazi\"}") { _key } } @@ -204,7 +204,7 @@ mutation { ```graphql mutation { - update_book(filter: {name: {_eq: "Gulistan"}}, data: "{\"description\": \"Persian poetry of ideas\"}") { + update_Book(filter: {name: {_eq: "Gulistan"}}, data: "{\"description\": \"Persian poetry of ideas\"}") { _key } } @@ -219,13 +219,13 @@ Note: The developer can create as many books they require by using this pattern. ```graphql query { - author { - name - dateOfBirth - authoredBooks { - name - genre - description + Author { + name + dateOfBirth + authoredBooks { + name + genre + description } } } @@ -255,10 +255,10 @@ query { ```graphql query { - book { + Book { name genre - author { + Author { name dateOfBirth } @@ -272,7 +272,7 @@ query { { "name": "Gulistan", "genre": "Poetry", - "author": { + "Author": { "name": "Saadi Shirazi", "dateOfBirth": "1210-07-23T03:46:56.647Z", } @@ -280,7 +280,7 @@ query { { "name": "Bustan", "genre": "Poetry", - "author": { + "Author": { "name": "Saadi Shirazi", "dateOfBirth": "1210-07-23T03:46:56.647Z", } @@ -290,7 +290,7 @@ query { ```graphql query { - author { + Author { name dateOfBirth authoredBooks(filter: {name: {_eq: "Gulistan"}}) { @@ -321,7 +321,7 @@ query { query { # Filters on the parent object can reference child fields # even if they are not requested. - author(filter: {authoredBooks: {name: {_eq: "Gulistan"}}}) { + Author(filter: {authoredBooks: {name: {_eq: "Gulistan"}}}) { name dateOfBirth } diff --git a/docs/guides/time-traveling-queries.md b/docs/guides/time-traveling-queries.md index 7dab757..0c95286 100644 --- a/docs/guides/time-traveling-queries.md +++ b/docs/guides/time-traveling-queries.md @@ -19,12 +19,12 @@ A powerful feature of a time-traveling query is that very little work is require # Here we fetch a User of the given dockey, in the state that it was at # at the commit matching the given CID. query { - Users ( + User ( cid: "bafybeieqnthjlvr64aodivtvtwgqelpjjvkmceyz4aqerkk5h23kjoivmu", dockey: "bae-52b9170d-b77a-5887-b877-cbdbb99b009f" ) { - Name - Age + name + age } } ``` diff --git a/docs/intro.md b/docs/intro.md index cafb8ea..2538edd 100644 --- a/docs/intro.md +++ b/docs/intro.md @@ -38,7 +38,7 @@ In this document, we use the default configuration, which has the following beha - `~/.defradb/` is DefraDB's configuration and data directory - `client` command interacts with the locally running node -- The GraphQL endpoint is provided at http://localhost:9181/api/v0/graphql +- The GraphQL endpoint is provided at The GraphQL endpoint can be used with a GraphQL client (e.g., Altair) to conveniently perform requests (`query`, `mutation`) and obtain schema introspection. diff --git a/docs/references/query-specification/aggregate-functions.md b/docs/references/query-specification/aggregate-functions.md index 792be52..4825698 100644 --- a/docs/references/query-specification/aggregate-functions.md +++ b/docs/references/query-specification/aggregate-functions.md @@ -12,7 +12,7 @@ The special aggregate function fields' format is the function name and the field Let us augment the previous grouped books by genre example and include an aggregate function on the sub-groups ratings. ```graphql { - books(filter: {author: {name: {_like: "John%"}}}, groupBy: [genre]) { + Books(filter: {author: {name: {_like: "John%"}}}, groupBy: [genre]) { genre _avg { rating @@ -33,7 +33,7 @@ We can also use simpler queries, without any `groupBy` clause, and still use agg Let's simply count all the objects returned by a given filter. ```graphql { - books(filter: {rating: {_gt: 3.5}}) { + Books(filter: {rating: {_gt: 3.5}}) { title _count } @@ -56,14 +56,14 @@ In addition to filtering using the `having` argument, we can still use `limit` a Let us get all the books from the author John LeCare, group them by genre, calculate the average rating of these books, select the groups with at least an average rating of 3.5, and order them from highest to lowest. ```graphql { - books(filter{ author: {name: "John LeCare"} }, groupBy: [genre], having: { _avg: {rating: {_gt: 3.5}}}, order: { _avg: {rating: DESC}}) { + Books(filter{ author: {name: "John LeCare"} }, groupBy: [genre], having: { _avg: {rating: {_gt: 3.5}}}, order: { _avg: {rating: DESC}}) { genre _avg { rating } _avg(field: rating) - books: _group{ + Books: _group{ title rating description diff --git a/docs/references/query-specification/aliases.md b/docs/references/query-specification/aliases.md index 1b51193..acd5db1 100644 --- a/docs/references/query-specification/aliases.md +++ b/docs/references/query-specification/aliases.md @@ -8,7 +8,7 @@ If the structure of a returned query is not ideal for a given application, you c ```graphql { - topTenBooks: books(sort: {rating: DESC}, limit: 10) { + topTenBooks: Books(sort: {rating: DESC}, limit: 10) { title genre description @@ -20,13 +20,13 @@ In the above example, the books result is renamed to `topTenBooks`, which can be ```graphql { - topTenBooks: books(sort: {rating: DESC}, limit: 10) { + topTenBooks: Books(sort: {rating: DESC}, limit: 10) { title genre description } - bottomTenBooks: books(sort: {rating: ASC}, limit: 10) { + bottomTenBooks: Books(sort: {rating: ASC}, limit: 10) { title genre description @@ -40,7 +40,7 @@ Additionally, we can alias individual fields within our returned types. Aliasing ```graphql { - books { + Books { name: title genre description diff --git a/docs/references/query-specification/database-api.md b/docs/references/query-specification/database-api.md index d4a37e6..acdc6de 100644 --- a/docs/references/query-specification/database-api.md +++ b/docs/references/query-specification/database-api.md @@ -71,7 +71,7 @@ query { To query a specific commit: ```graphql query { - commit(cid: 'Qm123') { + Commit(cid: 'Qm123') { cid height delta { @@ -85,7 +85,7 @@ In addition to using `Commit` specific queries, include commit version sub-field ```graphql query { - user { + User { _key name age diff --git a/docs/references/query-specification/filtering.md b/docs/references/query-specification/filtering.md index 9a180f2..23dbcdb 100644 --- a/docs/references/query-specification/filtering.md +++ b/docs/references/query-specification/filtering.md @@ -10,7 +10,7 @@ An empty `filter` object is equivalent to no filters being applied. Hence, the o ```graphql { - books(filter: {}) { + Books(filter: {}) { title genre description @@ -24,7 +24,7 @@ To apply a filter to a specific field, we can specify it within the filter objec ```graphql { - books(filter: { title: { _eq: "A Painted House" }}) { + Books(filter: { title: { _eq: "A Painted House" }}) { title genre description @@ -38,7 +38,7 @@ We can apply filters to all or multiple fields available. ```graphql { - books(filter: { title: {_eq: "A Painted House"}, genre: {_eq: "Thriller" }}) { + Books(filter: { title: {_eq: "A Painted House"}, genre: {_eq: "Thriller" }}) { title genre description @@ -52,11 +52,11 @@ Filters can also be applied on subfields that have relational objects within the ```graphql { - books(filter: { genre: {_eq: "Thriller"}, author: {name: {_eq: "John Grisham"}}}) { + Books(filter: { genre: {_eq: "Thriller"}, author: {name: {_eq: "John Grisham"}}}) { title genre description - author { + Author { name bio } @@ -72,7 +72,7 @@ This applies to both single sub-objects and array sub-objects, i.e., if we apply ```graphql { - authors(filter: {book: {genre: {_eq: "Thriller"}}}) { + Authors(filter: {book: {genre: {_eq: "Thriller"}}}) { name bio } @@ -81,10 +81,10 @@ This applies to both single sub-objects and array sub-objects, i.e., if we apply Additionally, in the selection set, if we include the sub-object array we are filtering on, the filter is then implicitly applied unless otherwise specified. -In the quercode snippet above, let's add `books` to the selection set using the query below . +In the query snippet above, let's add `books` to the selection set using the query below . ```graphql { - authors(filter: {book: {genre: {_eq: "Thriller"}}}) { + Authors(filter: {book: {genre: {_eq: "Thriller"}}}) { name bio books { @@ -99,7 +99,7 @@ Here, the `books` section will only contain books that match the root object fil ```graphql { - authors(filter: {book: {genre: {_eq: "Thriller"}}}) { + Authors(filter: {book: {genre: {_eq: "Thriller"}}}) { name bio books(filter: {}) { @@ -116,7 +116,7 @@ Filters applied solely to sub-objects, which are only applicable for array types ```graphql { - authors(filter: {name: {_eq: "John Grisham"}}) { + Authors(filter: {name: {_eq: "John Grisham"}}) { name bio books(filter: { genre: {_eq: "Thriller" }}) { @@ -138,7 +138,7 @@ Let's query for all books with a rating greater than or equal to 4. ```graphql { - books(filter: { rating: { _gte: 4 } }) { + Books(filter: { rating: { _gte: 4 } }) { title genre description @@ -181,7 +181,7 @@ The code snippet below queries all books that are a part of the Thriller genre, ```graphql { - books( + Books( filter: { _or: [ {genre: {_eq: "Thriller"}}, diff --git a/docs/references/query-specification/grouping.md b/docs/references/query-specification/grouping.md index f2dcc78..babbc67 100644 --- a/docs/references/query-specification/grouping.md +++ b/docs/references/query-specification/grouping.md @@ -11,7 +11,7 @@ Once one or more group by fields have been selected using the `groupBy` argument In the example below, we are querying for all the books whose author's name begins with 'John'. The results will then be grouped by genre, and will return the genre name and the sub-groups `title` and `rating`. ```graphql { - books(filter: {author: {name: {_like: "John%"}}}, groupBy: [genre]) { + Books(filter: {author: {name: {_like: "John%"}}}, groupBy: [genre]) { genre _group { title @@ -29,7 +29,7 @@ It's important to note that in the above example, the only available field from As mentioned, we can include any number of fields in the `groupBy` argument to segment the data further. Which can then also be accessed in the return object, as demonstrated in the example below: ```graphql { - books(filter: {author: {name: {_like: "John%"}}}, groupBy: [genre, rating]) { + Books(filter: {author: {name: {_like: "John%"}}}, groupBy: [genre, rating]) { genre rating _group { @@ -57,16 +57,16 @@ type Book { } type Author { - name string - written [Book] @relation + name: String + written: [Book] @relation } ``` We can create a group query over books and their authors, as demonstrated in the example below: ```graphql { - books(groupBy: [author]) { - author { + Books(groupBy: [author]) { + Author { name } _group { diff --git a/docs/references/query-specification/limiting-and-pagination.md b/docs/references/query-specification/limiting-and-pagination.md index 5a17f7c..fd5577e 100644 --- a/docs/references/query-specification/limiting-and-pagination.md +++ b/docs/references/query-specification/limiting-and-pagination.md @@ -9,7 +9,7 @@ After filtering and sorting a query, we can then limit and skip elements from th Let us get the top 10 rated books: ```graphql { - books(sort: {rating: DESC}, limit: 10) { + Books(sort: {rating: DESC}, limit: 10) { title genre description @@ -22,7 +22,7 @@ The `limit` function accepts the maximum number of items to return from the resu Let's get the *next* top 10 rated books after the previous query: ```graphql { - books(sort: {rating: DESC}, limit:10, offset: 10) { + Books(sort: {rating: DESC}, limit:10, offset: 10) { title genre description diff --git a/docs/references/query-specification/mutation-block.md b/docs/references/query-specification/mutation-block.md index 3d50bcc..532f126 100644 --- a/docs/references/query-specification/mutation-block.md +++ b/docs/references/query-specification/mutation-block.md @@ -16,8 +16,9 @@ Insert is used to create new documents from scratch. This involves many necessar ```graphql type Book { ... } + mutation { - createBook(data: createBookPayload) [Book] + create_Book(data: createBookPayload) [Book] } ``` @@ -28,6 +29,7 @@ The above example displays the general structure of an insert mutation. You call All mutations use a payload to update the data. Unlike the rest of the Query system, mutation payloads aren't typed. Instead, they use a standard JSON Serialization format. Removing the type system from payloads allows flexibility in the system. JSON Supports all the same types as DefraDB, and it's familiar for developers. Hence, it is an obvious choice for us. The following is an example with a full type and payload: + ```graphql type Book { title: String @@ -36,7 +38,7 @@ type Book { } mutation { - createBook(data: "{ + create_Book(data: "{ 'title': 'Painted House', 'description': 'The story begins as Luke Chandler ...', 'rating': 4.9 @@ -63,7 +65,7 @@ Update filters use the same format and types from the Query system. Hence, it ea The structure of the generated update mutation for a `Book` type is given below: ```graphql mutation { - update_book(id: ID, filter: BookFilterArg, data: updateBookPayload) [Book] + update_Book(id: ID, filter: BookFilterArg, data: updateBookPayload) [Book] } ``` @@ -88,7 +90,7 @@ Once we create our update, and select which document(s) to update, we can query A basic example is provided below: ```graphql mutation { - update_book(id: '123', data: "{'name': 'John'}") { + update_Book(id: '123', data: "{'name': 'John'}") { _key name } @@ -102,7 +104,7 @@ Beyond updating by an ID or IDs, we can use a query filter to select which field ```graphql mutation { - update_book(filter: {rating: {_le: 1.0}}, data: "{'rating': '1.5'}") { + update_Book(filter: {rating: {_le: 1.0}}, data: "{'rating': '1.5'}") { _key rating name @@ -127,14 +129,14 @@ The document selection interface is identical to the `Update` system. Much like The structure of the generated delete mutation for a `Book` type is given below: ```graphql mutation { - delete_book(id: ID, ids: [ID], filter: BookFilterArg) [Book] + delete_Book(id: ID, ids: [ID], filter: BookFilterArg) [Book] } ``` Here, we can delete a document with ID '123': ```graphql mutation { - delete_user(id: '123') { + delete_User(id: '123') { _key name } @@ -146,9 +148,10 @@ This will delete the specific document, and return the `_key` and `name` for the DefraDB currently uses a Hard Delete system, which means that when a document is deleted, it is completely removed from the database. Similar to the Update system, you can use a filter to select which documents to delete, as shown below: + ```graphql mutation { - delete_user(filter: {rating: {_gt: 3}}) { + delete_User(filter: {rating: {_gt: 3}}) { _key name } diff --git a/docs/references/query-specification/relationships.md b/docs/references/query-specification/relationships.md index bd31113..bfecbf3 100644 --- a/docs/references/query-specification/relationships.md +++ b/docs/references/query-specification/relationships.md @@ -41,15 +41,15 @@ Let us define a one-to-many relationship between an author and their books below ```graphql type Author { - name string - books [Book] + name: String + books: [Book] } type Book { - title string - genre string - description string - author Author + title: String + genre: String + description: String + author: Author } ``` @@ -81,8 +81,8 @@ type Author { type Book { title: String genre: String - author Author @relation(name: "written_books") - reviewedBy Author @relation(name: "reviewed_books") + author: Author @relation(name: "written_books") + reviewedBy: Author @relation(name: "reviewed_books") } ``` diff --git a/docs/references/query-specification/sorting-and-ordering.md b/docs/references/query-specification/sorting-and-ordering.md index 2ad0d9a..2ea69c1 100644 --- a/docs/references/query-specification/sorting-and-ordering.md +++ b/docs/references/query-specification/sorting-and-ordering.md @@ -9,7 +9,7 @@ Sorting is an integral part of any Database and Query Language. The sorting synt The query to find all books ordered by their latest published date: ```graphql { - books(sort: { published_at: “desc”}) { + Books(sort: { published_at: “desc”}) { title description published_at @@ -25,7 +25,7 @@ Sorting can be applied to multiple fields in the same query. The sort order is s The query below finds all books ordered by earliest published date and then by descending order of titles. ```graphql { - books(sort: { published_at: ASC, title: DESC }) { + Books(sort: { published_at: ASC, title: DESC }) { title genre description @@ -38,11 +38,11 @@ Additionally, you can sort sub-object fields along with root object fields. The query below finds all books ordered by earliest published date and then by the latest authors' birthday. ```graphql { - books(sort: { published_at: ASC, author: { birthday: DESC }}) { + Books(sort: { published_at: ASC, Author: { birthday: DESC }}) { title description published_at - author { + Author { name birthday } @@ -63,9 +63,9 @@ If the DocKey is included in the sort fields, any field included afterwards will *So, instead of:* ```graphql { - authors(sort: { name: DESC, books: { title: ASC }}) { + Authors(sort: { name: DESC, Books: { title: ASC }}) { name - books { + Books { title } } @@ -74,9 +74,9 @@ If the DocKey is included in the sort fields, any field included afterwards will *We need:* ```graphql { - authors(sort: { name: DESC }) { + Authors(sort: { name: DESC }) { name - books(sort: { title: ASC }) { + Books(sort: { title: ASC }) { title } } @@ -85,25 +85,25 @@ If the DocKey is included in the sort fields, any field included afterwards will >Root level filters and order only apply to root object. If you allow the initial version of the query, it would be confusing if the ordering applied to the order of the root object compared to its sibling objects or if the ordering applied solely to the sub-object. ->If you allow it, it enforces the semantics of root level sorting on array sub-objects to act as a sorting mechanism for the root object. As a result, there is no obvious way to determine which value in the array is used for the root order.[color=orange] +>If you allow it, it enforces the semantics of root level sorting on array sub-objects to act as a sorting mechanism for the root object. As a result, there is no obvious way to determine which value in the array is used for the root order. If you have the following objects in the database: ```json [ - "author" { + "Author" { "name": "John Grisham", "books": [ { "title": "A Painted House" }, { "title": "The Guardians" } ] }, - "author" { + "Author" { "name": "John Grisham", "books": [ { "title": "Camino Winds" }, ] }, - "author" { + "Author" { "name": "John LeCare", "books": [ { "title": "Tinker, Tailor, Soldier, Spy"} @@ -111,10 +111,10 @@ If you have the following objects in the database: } ] ``` -> and the following query [color=orange] +> and the following query ```graphql { - authors(sort: { name: DESC, books: { title: ASC }}) { + Authors(sort: { name: DESC, books: { title: ASC }}) { name books { title @@ -124,13 +124,13 @@ If you have the following objects in the database: ``` ```graphql -books(filter: {_id: [1]}) { +Books(filter: {_id: [1]}) { title genre description } ``` -> Given there are two authors with the same name (John Grisham), the sort object `(sort: { name: "desc", books: { title: "asc" }}` would suggest we sort duplicate authors using `books: { title: "asc" }` as the secondary sort field. However, because the books field is an array of objects, there is no single value for the title to compare easily. [color=orange] +> Given there are two authors with the same name (John Grisham), the sort object `(sort: { name: "desc", Books: { title: "asc" }}` would suggest we sort duplicate authors using `Books: { title: "asc" }` as the secondary sort field. However, because the books field is an array of objects, there is no single value for the title to compare easily. > > Therefore, sorting on array sub objects from the root field is ***strictly not allowed***. diff --git a/docs/references/query-specification/variables.md b/docs/references/query-specification/variables.md index 7cf9223..1e9345e 100644 --- a/docs/references/query-specification/variables.md +++ b/docs/references/query-specification/variables.md @@ -12,7 +12,7 @@ Input variables can be used in place of complex string interpolation to allow fo ```graphql query($myVar: Int) { - books(filter{ rating: $myVar}) { + Books(filter{ rating: $myVar}) { title genre description @@ -43,11 +43,11 @@ Subquery results, represented by the prefixed variable, can be used as many othe ```graphql # Select all books published by X reviewed by authors belonging to a publisher Y { - _authorsOfPubY: authors(filter: { written: { publishedBy: {name: "Y"}}}) { + _authorsOfPubY: Authors(filter: { written: { publishedBy: {name: "Y"}}}) { _id } - books(filter: {publishedBy: { name: "X" }, reviewedBy: {_in: $_authorsOfPubY}}) { + Books(filter: {publishedBy: { name: "X" }, reviewedBy: {_in: $_authorsOfPubY}}) { title genre description