-
Notifications
You must be signed in to change notification settings - Fork 259
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(2639): implement entity resolver (#2693)
Co-authored-by: Tushar Mathur <[email protected]> Co-authored-by: Amit Singh <[email protected]>
- Loading branch information
1 parent
b0bcfcf
commit c062058
Showing
64 changed files
with
5,474 additions
and
381 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
schema | ||
@server(port: 8001) | ||
@upstream(baseURL: "http://jsonplaceholder.typicode.com", httpCache: 42, batch: {delay: 100}) { | ||
query: Query | ||
} | ||
|
||
type Query { | ||
posts: [Post] @http(path: "/posts") | ||
} | ||
|
||
type User @http(path: "/users", query: [{key: "id", value: "{{.value.id}}"}], batchKey: ["id"]) { | ||
id: Int! | ||
} | ||
|
||
type Post @http(path: "/posts", query: [{key: "id", value: "{{.value.id}}"}], batchKey: ["id"]) { | ||
id: Int! | ||
userId: Int! | ||
title: String! | ||
body: String! | ||
user: User @expr(body: {id: "{{.value.userId}}"}) | ||
} |
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,18 @@ | ||
schema | ||
@server(port: 8002) | ||
@upstream(baseURL: "http://jsonplaceholder.typicode.com", httpCache: 42, batch: {delay: 100}) { | ||
query: Query | ||
} | ||
|
||
type Query { | ||
user(id: Int!): User @http(path: "/users/{{.args.id}}") | ||
} | ||
|
||
type User @http(path: "/users", query: [{key: "id", value: "{{.value.id}}"}], batchKey: ["id"]) { | ||
id: Int! | ||
name: String | ||
username: String | ||
email: String | ||
phone: String | ||
website: String | ||
} |
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,28 @@ | ||
# Apollo Federation example | ||
|
||
1. Start tailcall subgraph examples: | ||
|
||
- `cargo run -- start examples/apollo_federation_subgraph_post.graphql` | ||
- `cargo run -- start examples/apollo_federation_subgraph_user.graphql` | ||
|
||
2. Run Apollo router by one of the following methods: | ||
|
||
- run `@apollo/gateway` with `npm start` (with `npm install` for the first time) from "examples/federation" folder | ||
- start apollo router with `rover.sh` script (install [apollo rover](https://www.apollographql.com/docs/rover) first) | ||
|
||
3. Navigate to `http://localhost:4000` and execute supergraph queries, see [examples](#query-examples) | ||
|
||
# Query examples | ||
|
||
```graphql | ||
{ | ||
posts { | ||
id | ||
title | ||
user { | ||
id | ||
name | ||
} | ||
} | ||
} | ||
``` |
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,20 @@ | ||
import {ApolloServer} from "@apollo/server" | ||
import {startStandaloneServer} from "@apollo/server/standalone" | ||
import {ApolloGateway, IntrospectAndCompose} from "@apollo/gateway" | ||
|
||
const gateway = new ApolloGateway({ | ||
supergraphSdl: new IntrospectAndCompose({ | ||
subgraphs: [ | ||
{name: "post", url: "http://localhost:8001/graphql"}, | ||
{name: "user", url: "http://localhost:8002/graphql"}, | ||
], | ||
}), | ||
}) | ||
|
||
const server = new ApolloServer({ | ||
gateway, | ||
introspection: true, | ||
}) | ||
|
||
const {url} = await startStandaloneServer(server) | ||
console.log(`🚀 Server ready at ${url}`) |
Oops, something went wrong.
c062058
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
260480 requests in 30.03s, 1.31GB read
Requests/sec: 8675.13
Transfer/sec: 44.53MB