Skip to content
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

fix: Resolving multiple issues: casing, some incorrect GraphQL queries, details #122

Merged
merged 4 commits into from
May 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 9 additions & 6 deletions docs/guides/explain-systems.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ The DefraDB Explain System is a powerful tool designed to introspect requests, e

```graphql
query {
author {
Author {
_key
name
age
Expand All @@ -24,7 +24,7 @@ query {

```graphql
query @explain {
author {
Author {
_key
name
age
Expand Down Expand Up @@ -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
}
}
```

Expand All @@ -96,7 +99,7 @@ query @explain {
"scanNode": {
"filter":null,
"collectionID": "3",
"collectionName": "author",
"collectionName": "Author",
"spans": [{
"start": "/3",
"end": "/4"
Expand All @@ -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
}
Expand Down
68 changes: 34 additions & 34 deletions docs/guides/schema-relationship.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
```

Expand All @@ -73,31 +73,31 @@ 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
}
}
```

```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
Expand All @@ -109,11 +109,11 @@ query {

```graphql
query {
address {
Address {
streetNumber
streetName
country
user {
User {
name
username
age
Expand All @@ -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
Expand All @@ -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
}

```
Expand All @@ -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
}
}
Expand All @@ -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
}
}
Expand All @@ -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
}
}
Expand All @@ -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
}
}
Expand All @@ -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
}
}
}
Expand Down Expand Up @@ -255,10 +255,10 @@ query {

```graphql
query {
book {
Book {
name
genre
author {
Author {
name
dateOfBirth
}
Expand All @@ -272,15 +272,15 @@ query {
{
"name": "Gulistan",
"genre": "Poetry",
"author": {
"Author": {
"name": "Saadi Shirazi",
"dateOfBirth": "1210-07-23T03:46:56.647Z",
}
},
{
"name": "Bustan",
"genre": "Poetry",
"author": {
"Author": {
"name": "Saadi Shirazi",
"dateOfBirth": "1210-07-23T03:46:56.647Z",
}
Expand All @@ -290,7 +290,7 @@ query {

```graphql
query {
author {
Author {
name
dateOfBirth
authoredBooks(filter: {name: {_eq: "Gulistan"}}) {
Expand Down Expand Up @@ -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
}
Expand Down
6 changes: 3 additions & 3 deletions docs/guides/time-traveling-queries.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
```
Expand Down
2 changes: 1 addition & 1 deletion docs/intro.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 <http://localhost:9181/api/v0/graphql>

The GraphQL endpoint can be used with a GraphQL client (e.g., Altair) to conveniently perform requests (`query`, `mutation`) and obtain schema introspection.

Expand Down
8 changes: 4 additions & 4 deletions docs/references/query-specification/aggregate-functions.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
}
Expand All @@ -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
Expand Down
8 changes: 4 additions & 4 deletions docs/references/query-specification/aliases.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -40,7 +40,7 @@ Additionally, we can alias individual fields within our returned types. Aliasing

```graphql
{
books {
Books {
name: title
genre
description
Expand Down
4 changes: 2 additions & 2 deletions docs/references/query-specification/database-api.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ query {
To query a specific commit:
```graphql
query {
commit(cid: 'Qm123') {
Commit(cid: 'Qm123') {
cid
height
delta {
Expand All @@ -85,7 +85,7 @@ In addition to using `Commit` specific queries, include commit version sub-field

```graphql
query {
user {
User {
_key
name
age
Expand Down
Loading