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

more integration tests #6035

Draft
wants to merge 12 commits into
base: dev
Choose a base branch
from
3 changes: 3 additions & 0 deletions apollo-router/tests/samples/basic/inaccessible/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Inaccessible

Test the `inaccessible` directive.
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
126 changes: 126 additions & 0 deletions apollo-router/tests/samples/basic/inaccessible/plan.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
{
"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"
}
}
}
}
},
{
"request": {
"body": {
"query": "{me{__typename id name}}"
}
},
"response": {
"body": {
"data": {
"me": {
"__typename": "User",
"id": "1",
"name": "test"
}
}
}
}
}
]
},
"reviews": {
"requests": [
{
"request": {
"body": {
"query": "query($representations:[_Any!]!){_entities(representations:$representations){...on User{reviews{body}}}}",
"variables": {
"representations": [
{
"__typename": "User",
"id": "1"
}
]
}
}
},
"response": {
"body": {
"data": {
"_entities": [
{
"reviews": [
{
"body": "test"
}
]
}
]
}
}
}
}
]
}
}
},
{
"type": "Request",
"request": {
"query": "{ topProducts { upc name } }"
},
"expected_response": {
"errors": [
{
"message": "Cannot query field \"upc\" on type \"Product\".",
"locations": [
{
"line": 1,
"column": 17
}
],
"extensions": {
"code": "GRAPHQL_VALIDATION_FAILED"
}
}
]
}
},
{
"type": "Request",
"request": {
"query": "{ me { name reviews { body } } }"
},
"expected_response": {
"data": {
"me": {
"name": "test",
"reviews": [
{
"body": "test"
}
]
}
}
}
},
{
"type": "Stop"
}
]
}
103 changes: 103 additions & 0 deletions apollo-router/tests/samples/basic/inaccessible/supergraph.graphql
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
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
}

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
scalar link__Import

enum join__Graph {
ACCOUNTS
@join__graph(name: "accounts", url: "https://accounts.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/")
}

enum link__Purpose {
SECURITY
EXECUTION
}

type Product
@join__type(graph: PRODUCTS, key: "upc")
@join__type(graph: REVIEWS, key: "upc") {
name: String @join__field(graph: PRODUCTS)
reviews: [Review] @join__field(graph: REVIEWS)
reviewsForAuthor(authorID: ID!): [Review] @join__field(graph: REVIEWS)
upc: String! @inaccessible
}

type Query
@join__type(graph: ACCOUNTS)
@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! @inaccessible
author: User @join__field(graph: REVIEWS, provides: "username")
body: String @join__field(graph: REVIEWS)
product: Product @join__field(graph: REVIEWS)
}

type User
@join__type(graph: ACCOUNTS, key: "id")
@join__type(graph: REVIEWS, key: "id") {
id: ID! @inaccessible
name: String @join__field(graph: ACCOUNTS)
username: String
@join__field(graph: ACCOUNTS)
@join__field(graph: REVIEWS, external: true) @inaccessible
reviews: [Review] @join__field(graph: REVIEWS)
}
4 changes: 4 additions & 0 deletions apollo-router/tests/samples/basic/requires/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@

# Requires

Test the `requires` directive.
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
override_subgraph_url:
products: http://localhost:4005
include_subgraph_errors:
all: true

plugins:
experimental.expose_query_plan: true
Loading
Loading