-
Notifications
You must be signed in to change notification settings - Fork 254
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(2911): add validation in federation resolvers (#3102)
- Loading branch information
Showing
3 changed files
with
152 additions
and
10 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
27 changes: 27 additions & 0 deletions
27
tests/core/snapshots/apollo-federation-validation.md_error.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,27 @@ | ||
--- | ||
source: tests/core/spec.rs | ||
expression: errors | ||
--- | ||
[ | ||
{ | ||
"message": "Type 'AccountType' not found in config", | ||
"trace": [ | ||
"Account" | ||
], | ||
"description": null | ||
}, | ||
{ | ||
"message": "Invalid key at index 0: 'blogId' is not a field of 'Blog'", | ||
"trace": [ | ||
"Blog" | ||
], | ||
"description": null | ||
}, | ||
{ | ||
"message": "Invalid key at index 1: 'userId' is not a field of 'Blog'", | ||
"trace": [ | ||
"User" | ||
], | ||
"description": null | ||
} | ||
] |
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,46 @@ | ||
--- | ||
error: true | ||
--- | ||
|
||
# Apollo federation validation | ||
|
||
```graphql @config | ||
schema @server(port: 8000, enableFederation: true) @upstream(httpCache: 42, batch: {delay: 100}) { | ||
query: Query | ||
} | ||
|
||
type Query { | ||
post(id: Int!): Post @http(url: "http://jsonplaceholder.typicode.com/posts/{{.args.id}}") | ||
} | ||
|
||
type User @http(url: "http://jsonplaceholder.typicode.com/users/{{.value.blog.userId}}") { | ||
id: Int! | ||
username: String! | ||
blog: Blog! | ||
} | ||
|
||
type Post | ||
@http( | ||
url: "http://jsonplaceholder.typicode.com/posts" | ||
query: [{key: "id", value: "{{.value.id}}"}] | ||
batchKey: ["blog", "blogId"] | ||
) { | ||
id: Int! | ||
blog: Blog! | ||
} | ||
|
||
type Account | ||
@http( | ||
url: "http://jsonplaceholder.typicode.com/posts" | ||
query: [{key: "id", value: "{{.value.type.id}}"}] | ||
batchKey: ["blog", "blogId"] | ||
) { | ||
id: Int! | ||
balance: Blog! | ||
type: AccountType | ||
} | ||
|
||
type Blog @http(url: "http://jsonplaceholder.typicode.com/posts", query: [{key: "id", value: "{{.value.blogId}}"}]) { | ||
id: Int! | ||
} | ||
``` |
d9baf52
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Running 30s test @ http://localhost:8000/graphql
4 threads and 100 connections
763950 requests in 30.01s, 3.83GB read
Requests/sec: 25456.82
Transfer/sec: 130.66MB