-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add fixture configuration for relations with test (#52)
Updates the integration test configuration with relations within the sample_mflix database. Adds an integration test using that configuration. Also adds another native query example that uses "collection" representation with an input collection. Removes MongoDB v4 from supported versions due to uses of `$getField` which was added in v5.
- Loading branch information
Showing
12 changed files
with
390 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
use crate::query; | ||
use insta::assert_yaml_snapshot; | ||
use serde_json::json; | ||
|
||
#[tokio::test] | ||
async fn joins_local_relationships() -> anyhow::Result<()> { | ||
assert_yaml_snapshot!( | ||
query( | ||
r#" | ||
query { | ||
movies(limit: 2, order_by: {title: Asc}, where: {title: {_iregex: "Rear"}}) { | ||
id | ||
title | ||
comments(limit: 2, order_by: {id: Asc}) { | ||
text | ||
movie { | ||
id | ||
title | ||
} | ||
user { | ||
comments(limit: 2, order_by: {id: Asc}) { | ||
text | ||
user { | ||
comments(limit: 2, order_by: {id: Asc}) { | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
"# | ||
) | ||
.variables(json!({ "limit": 11, "movies_limit": 2 })) | ||
.run() | ||
.await? | ||
); | ||
Ok(()) | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,6 +8,7 @@ | |
// | ||
|
||
mod basic; | ||
mod local_relationship; | ||
mod native_procedure; | ||
mod native_query; | ||
mod remote_relationship; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
61 changes: 61 additions & 0 deletions
61
...ts/snapshots/integration_tests__tests__local_relationship__joins_local_relationships.snap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
--- | ||
source: crates/integration-tests/src/tests/local_relationship.rs | ||
expression: "query(r#\"\n query {\n movies(limit: 2, order_by: {title: Asc}, where: {title: {_iregex: \"Rear\"}}) {\n id\n title\n comments(limit: 2, order_by: {id: Asc}) {\n email\n text\n movie {\n id\n title\n }\n user {\n email\n comments(limit: 2, order_by: {id: Asc}) {\n email\n text\n user {\n email\n comments(limit: 2, order_by: {id: Asc}) {\n email\n }\n }\n }\n }\n }\n }\n }\n \"#).variables(json!({\n \"limit\": 11, \"movies_limit\": 2\n })).run().await?" | ||
--- | ||
data: | ||
movies: | ||
- comments: | ||
- email: iain_glen@gameofthron.es | ||
movie: | ||
id: | ||
$oid: 573a1398f29313caabceb0b1 | ||
title: A Night in the Life of Jimmy Reardon | ||
text: Debitis tempore cum natus quaerat dolores quibusdam perferendis. Pariatur aspernatur officia libero quod pariatur nobis neque. Maiores non ipsam iste repellendus distinctio praesentium iure. | ||
user: | ||
comments: | ||
- email: iain_glen@gameofthron.es | ||
text: Minus sequi incidunt cum magnam. Quam voluptatum vitae ab voluptatum cum. Autem perferendis nisi nulla dolores aut recusandae. | ||
user: | ||
comments: | ||
- email: iain_glen@gameofthron.es | ||
- email: iain_glen@gameofthron.es | ||
email: iain_glen@gameofthron.es | ||
- email: iain_glen@gameofthron.es | ||
text: Impedit consectetur ex cupiditate enim. Placeat assumenda reiciendis iste neque similique nesciunt aperiam. | ||
user: | ||
comments: | ||
- email: iain_glen@gameofthron.es | ||
- email: iain_glen@gameofthron.es | ||
email: iain_glen@gameofthron.es | ||
email: iain_glen@gameofthron.es | ||
id: | ||
$oid: 573a1398f29313caabceb0b1 | ||
title: A Night in the Life of Jimmy Reardon | ||
- comments: | ||
- email: owen_teale@gameofthron.es | ||
movie: | ||
id: | ||
$oid: 573a1394f29313caabcdfa00 | ||
title: Rear Window | ||
text: Nobis corporis rem hic ipsa cum impedit. Esse nihil cum est minima ducimus temporibus minima. Sed reprehenderit tempore similique nam. Ipsam nesciunt veniam aut amet ut. | ||
user: | ||
comments: | ||
- email: owen_teale@gameofthron.es | ||
text: A ut dolor illum deleniti repellendus. Iste fugit in quas minus nobis sunt rem. Animi possimus dolor alias natus consequatur saepe. Nihil quam magni aspernatur nisi. | ||
user: | ||
comments: | ||
- email: owen_teale@gameofthron.es | ||
- email: owen_teale@gameofthron.es | ||
email: owen_teale@gameofthron.es | ||
- email: owen_teale@gameofthron.es | ||
text: Repudiandae repellat quia officiis. Quidem voluptatum vel id itaque et. Corrupti corporis magni voluptas quae itaque fugiat quae. | ||
user: | ||
comments: | ||
- email: owen_teale@gameofthron.es | ||
- email: owen_teale@gameofthron.es | ||
email: owen_teale@gameofthron.es | ||
email: owen_teale@gameofthron.es | ||
id: | ||
$oid: 573a1394f29313caabcdfa00 | ||
title: Rear Window | ||
errors: ~ |
57 changes: 57 additions & 0 deletions
57
...gration_tests__tests__native_query__runs_native_query_with_collection_representation.snap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
--- | ||
source: crates/integration-tests/src/tests/native_query.rs | ||
expression: "query(r#\"\n query {\n title_word_frequencies(\n where: {count: {_eq: 2}}\n order_by: {word: Asc}\n offset: 100\n limit: 25\n ) {\n word\n count\n }\n }\n \"#).run().await?" | ||
--- | ||
data: | ||
title_word_frequencies: | ||
- count: 2 | ||
word: Amish | ||
- count: 2 | ||
word: Amor? | ||
- count: 2 | ||
word: Anara | ||
- count: 2 | ||
word: Anarchy | ||
- count: 2 | ||
word: Anastasia | ||
- count: 2 | ||
word: Anchorman | ||
- count: 2 | ||
word: Andre | ||
- count: 2 | ||
word: Andrei | ||
- count: 2 | ||
word: Andromeda | ||
- count: 2 | ||
word: Andrè | ||
- count: 2 | ||
word: Angela | ||
- count: 2 | ||
word: Angelica | ||
- count: 2 | ||
word: "Angels'" | ||
- count: 2 | ||
word: "Angels:" | ||
- count: 2 | ||
word: Angst | ||
- count: 2 | ||
word: Animation | ||
- count: 2 | ||
word: Annabelle | ||
- count: 2 | ||
word: Anonyma | ||
- count: 2 | ||
word: Anonymous | ||
- count: 2 | ||
word: Answer | ||
- count: 2 | ||
word: Ant | ||
- count: 2 | ||
word: Antarctic | ||
- count: 2 | ||
word: Antoinette | ||
- count: 2 | ||
word: Anybody | ||
- count: 2 | ||
word: Anywhere | ||
errors: ~ |
30 changes: 30 additions & 0 deletions
30
fixtures/connector/sample_mflix/native_queries/title_word_requency.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
{ | ||
"name": "title_word_frequency", | ||
"representation": "collection", | ||
"inputCollection": "movies", | ||
"description": "words appearing in movie titles with counts", | ||
"resultDocumentType": "TitleWordFrequency", | ||
"objectTypes": { | ||
"TitleWordFrequency": { | ||
"fields": { | ||
"_id": { "type": { "scalar": "string" } }, | ||
"count": { "type": { "scalar": "int" } } | ||
} | ||
} | ||
}, | ||
"pipeline": [ | ||
{ | ||
"$replaceWith": { | ||
"title_words": { "$split": ["$title", " "] } | ||
} | ||
}, | ||
{ "$unwind": { "path": "$title_words" } }, | ||
{ | ||
"$group": { | ||
"_id": "$title_words", | ||
"count": { "$count": {} } | ||
} | ||
} | ||
] | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
--- | ||
kind: ObjectType | ||
version: v1 | ||
definition: | ||
name: TitleWordFrequency | ||
fields: | ||
- name: word | ||
type: String! | ||
- name: count | ||
type: Int! | ||
graphql: | ||
typeName: TitleWordFrequency | ||
inputTypeName: TitleWordFrequencyInput | ||
dataConnectorTypeMapping: | ||
- dataConnectorName: sample_mflix | ||
dataConnectorObjectType: TitleWordFrequency | ||
fieldMapping: | ||
word: | ||
column: | ||
name: _id | ||
count: | ||
column: | ||
name: count | ||
|
||
--- | ||
kind: TypePermissions | ||
version: v1 | ||
definition: | ||
typeName: TitleWordFrequency | ||
permissions: | ||
- role: admin | ||
output: | ||
allowedFields: | ||
- word | ||
- count | ||
|
||
--- | ||
kind: ObjectBooleanExpressionType | ||
version: v1 | ||
definition: | ||
name: TitleWordFrequencyBoolExp | ||
objectType: TitleWordFrequency | ||
dataConnectorName: sample_mflix | ||
dataConnectorObjectType: TitleWordFrequency | ||
comparableFields: | ||
- fieldName: word | ||
operators: | ||
enableAll: true | ||
- fieldName: count | ||
operators: | ||
enableAll: true | ||
graphql: | ||
typeName: TitleWordFrequencyBoolExp | ||
|
||
--- | ||
kind: Model | ||
version: v1 | ||
definition: | ||
name: TitleWordFrequency | ||
objectType: TitleWordFrequency | ||
source: | ||
dataConnectorName: sample_mflix | ||
collection: title_word_frequency | ||
filterExpressionType: TitleWordFrequencyBoolExp | ||
orderableFields: | ||
- fieldName: word | ||
orderByDirections: | ||
enableAll: true | ||
- fieldName: count | ||
orderByDirections: | ||
enableAll: true | ||
graphql: | ||
selectMany: | ||
queryRootField: title_word_frequencies | ||
selectUniques: | ||
- queryRootField: title_word_frequency | ||
uniqueIdentifier: | ||
- word | ||
orderByExpressionType: TitleWordFrequencyOrderBy | ||
|
||
--- | ||
kind: ModelPermissions | ||
version: v1 | ||
definition: | ||
modelName: TitleWordFrequency | ||
permissions: | ||
- role: admin | ||
select: | ||
filter: null | ||
|
35 changes: 35 additions & 0 deletions
35
fixtures/ddn/sample_mflix/relationships/movie_comments.hml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
kind: Relationship | ||
version: v1 | ||
definition: | ||
name: comments | ||
source: Movies | ||
target: | ||
model: | ||
name: Comments | ||
relationshipType: Array | ||
mapping: | ||
- source: | ||
fieldPath: | ||
- fieldName: id | ||
target: | ||
modelField: | ||
- fieldName: movieId | ||
|
||
--- | ||
kind: Relationship | ||
version: v1 | ||
definition: | ||
name: movie | ||
source: Comments | ||
target: | ||
model: | ||
name: Movies | ||
relationshipType: Object | ||
mapping: | ||
- source: | ||
fieldPath: | ||
- fieldName: movieId | ||
target: | ||
modelField: | ||
- fieldName: id | ||
|
Oops, something went wrong.