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

defer integration tests #6007

Open
wants to merge 7 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
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
1 change: 0 additions & 1 deletion apollo-router/tests/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -582,7 +582,6 @@ impl IntegrationTest {

let mut request = builder.json(&query).build().unwrap();
telemetry.inject_context(&mut request);
request.headers_mut().remove(ACCEPT);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@BrynCooke do you remember why the integration tests were removing the Accept header from the request?

match client.execute(request).await {
Ok(response) => (span_id, response),
Err(err) => {
Expand Down
3 changes: 3 additions & 0 deletions apollo-router/tests/samples/basic/defer/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
This is an example test

This file adds some context that will be displayed on test failure
4 changes: 4 additions & 0 deletions apollo-router/tests/samples/basic/defer/configuration.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
override_subgraph_url:
products: http://localhost:4005
include_subgraph_errors:
all: true
53 changes: 53 additions & 0 deletions apollo-router/tests/samples/basic/defer/plan.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
{
"actions": [
{
"type": "Start",
"schema_path": "./supergraph.graphql",
"configuration_path": "./configuration.yaml",
"subgraphs": {
"accounts": {
"requests": [
{
"request": {
"body": {
"query": "{me{name}}"
}
},
"response": {
"body": {
"data": {
"me": {
"name": "test"
}
}
}
}
}
]
},
"reviews": {
"requests": []
}
}
},
{
"type": "Request",
"headers": {
"Accept": "multipart/mixed;deferSpec=20220824"
},
"request": {
"query": "{ me { name ... @defer { reviews { body } } } }"
},
"expected_response": {
"data": {
"me": {
"name": "Ada Lovelace"
}
}
}
},
{
"type": "Stop"
}
]
}
125 changes: 125 additions & 0 deletions apollo-router/tests/samples/basic/defer/supergraph.graphql
Original file line number Diff line number Diff line change
@@ -0,0 +1,125 @@
schema
@link(url: "https://specs.apollo.dev/link/v1.0")
@link(url: "https://specs.apollo.dev/inaccessible/v0.2", for: SECURITY)
@link(url: "https://specs.apollo.dev/join/v0.3", for: EXECUTION) {
query: Query
mutation: Mutation
}

directive @inaccessible on FIELD_DEFINITION | OBJECT | INTERFACE | UNION | ARGUMENT_DEFINITION | SCALAR | ENUM | ENUM_VALUE | INPUT_OBJECT | INPUT_FIELD_DEFINITION

directive @tag(
name: String!
) repeatable on FIELD_DEFINITION | OBJECT | INTERFACE | UNION | ARGUMENT_DEFINITION | SCALAR | ENUM | ENUM_VALUE | INPUT_OBJECT | INPUT_FIELD_DEFINITION | SCHEMA

directive @join__enumValue(graph: join__Graph!) repeatable on ENUM_VALUE

directive @join__field(
graph: join__Graph
requires: join__FieldSet
provides: join__FieldSet
type: String
external: Boolean
override: String
usedOverridden: Boolean
) repeatable on FIELD_DEFINITION | INPUT_FIELD_DEFINITION

directive @join__graph(name: String!, url: String!) on ENUM_VALUE

directive @join__implements(
graph: join__Graph!
interface: String!
) repeatable on OBJECT | INTERFACE

directive @join__type(
graph: join__Graph!
key: join__FieldSet
extension: Boolean! = false
resolvable: Boolean! = true
isInterfaceObject: Boolean! = false
) repeatable on OBJECT | INTERFACE | UNION | ENUM | INPUT_OBJECT | SCALAR

directive @join__unionMember(
graph: join__Graph!
member: String!
) repeatable on UNION

directive @link(
url: String
as: String
for: link__Purpose
import: [link__Import]
) repeatable on SCHEMA

scalar join__FieldSet

enum join__Graph {
ACCOUNTS
@join__graph(name: "accounts", url: "https://accounts.demo.starstuff.dev/")
INVENTORY
@join__graph(
name: "inventory"
url: "https://inventory.demo.starstuff.dev/"
)
PRODUCTS
@join__graph(name: "products", url: "https://products.demo.starstuff.dev/")
REVIEWS
@join__graph(name: "reviews", url: "https://reviews.demo.starstuff.dev/")
}

scalar link__Import

enum link__Purpose {
SECURITY
EXECUTION
}

type Mutation @join__type(graph: PRODUCTS) @join__type(graph: REVIEWS) {
createProduct(upc: ID!, name: String): Product @join__field(graph: PRODUCTS)
createReview(upc: ID!, id: ID!, body: String): Review
@join__field(graph: REVIEWS)
}

type Product
@join__type(graph: INVENTORY, key: "upc")
@join__type(graph: PRODUCTS, key: "upc")
@join__type(graph: REVIEWS, key: "upc") {
inStock: Boolean
@join__field(graph: INVENTORY)
@tag(name: "private")
@inaccessible
name: String @join__field(graph: PRODUCTS)
weight: Int @join__field(graph: INVENTORY, external: true) @join__field(graph: PRODUCTS)
price: Int @join__field(graph: INVENTORY, external: true) @join__field(graph: PRODUCTS)
reviews: [Review] @join__field(graph: REVIEWS)
reviewsForAuthor(authorID: ID!): [Review] @join__field(graph: REVIEWS)
shippingEstimate: Int @join__field(graph: INVENTORY, requires: "price weight")
upc: String!
}

type Query
@join__type(graph: ACCOUNTS)
@join__type(graph: INVENTORY)
@join__type(graph: PRODUCTS)
@join__type(graph: REVIEWS) {
me: User @join__field(graph: ACCOUNTS)
topProducts(first: Int = 5): [Product] @join__field(graph: PRODUCTS)
}

type Review @join__type(graph: REVIEWS, key: "id") {
id: ID!
body: String @join__field(graph: REVIEWS)
author: User @join__field(graph: REVIEWS, provides: "username")
product: Product @join__field(graph: REVIEWS)
}

type User
@join__type(graph: ACCOUNTS, key: "id")
@join__type(graph: REVIEWS, key: "id") {
id: ID!
name: String @join__field(graph: ACCOUNTS)
username: String
@join__field(graph: ACCOUNTS)
@join__field(graph: REVIEWS, external: true)
reviews: [Review] @join__field(graph: REVIEWS)
}
7 changes: 6 additions & 1 deletion apollo-router/tests/samples_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -446,7 +446,12 @@ impl TestExecution {
f
})?;
let graphql_response: Value = serde_json::from_slice(&body).map_err(|e| {
writeln!(out, "could not deserialize graphql response data: {e}").unwrap();
writeln!(
out,
"could not deserialize graphql response data: {e}\nfrom:\n{}",
std::str::from_utf8(&body).unwrap()
)
.unwrap();
let f: Failed = out.clone().into();
f
})?;
Expand Down
Loading