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

feat(2639): implement entity resolver #2693

Merged
merged 28 commits into from
Sep 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
64e3c53
refactor(config): represent field resolver as separate enum
meskill Aug 12, 2024
57e073b
Merge remote-tracking branch 'origin/main' into refactor/field-resolver
meskill Aug 13, 2024
5b3aec1
feat(federation): implement entity resolver
meskill Aug 14, 2024
ab0613e
Merge remote-tracking branch 'origin/main' into feat/federation-entit…
meskill Aug 15, 2024
0ce4b9f
Merge remote-tracking branch 'origin/main' into feat/federation-entit…
meskill Aug 19, 2024
78605c9
move directives definitions to separate modules
meskill Aug 20, 2024
dc57283
extend merge_right macro to support other types of struct
meskill Aug 20, 2024
9e76cb3
add federation _service support
meskill Aug 20, 2024
701e37b
fix lint
meskill Aug 21, 2024
eb5e2b5
rename example
meskill Aug 21, 2024
dc3b42c
Merge remote-tracking branch 'origin/main' into feat/federation-entit…
meskill Aug 21, 2024
7ea9b46
allow resolvable directives on types
meskill Aug 21, 2024
e3b0df3
provide tailcall specific directives to sdl
meskill Aug 21, 2024
f7dd6e9
update example
meskill Aug 21, 2024
857e611
fix example
meskill Aug 21, 2024
1baa0c7
fix lint
meskill Aug 21, 2024
2ec982e
fix snapshots
meskill Aug 21, 2024
db78e6c
Merge remote-tracking branch 'origin/main' into feat/federation-entit…
meskill Aug 27, 2024
abcbe01
refactor: reuse typename if possible
meskill Aug 27, 2024
10d9d60
Merge remote-tracking branch 'origin/main' into feat/federation-entit…
meskill Sep 16, 2024
db47156
Merge remote-tracking branch 'origin/main' into feat/federation-entit…
meskill Sep 17, 2024
d3cf597
Merge branch 'main' into feat/federation-entity-resolver
tusharmath Sep 18, 2024
23a9e82
Merge branch 'main' into feat/federation-entity-resolver
amitksingh1490 Sep 23, 2024
63bd4fe
fix snapshot tests
meskill Sep 23, 2024
a37d703
Merge branch 'main' into feat/federation-entity-resolver
amitksingh1490 Sep 24, 2024
bcaa98c
Merge branch 'main' into feat/federation-entity-resolver
tusharmath Sep 24, 2024
59cae80
fix review comments
meskill Sep 24, 2024
866bc3d
fix: directives name clashes with apollo federation for link (#2886)
meskill Sep 24, 2024
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
21 changes: 21 additions & 0 deletions examples/apollo_federation_subgraph_post.graphql
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}}"})
}
18 changes: 18 additions & 0 deletions examples/apollo_federation_subgraph_user.graphql
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
}
28 changes: 28 additions & 0 deletions examples/federation/README.md
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
}
}
}
```
20 changes: 20 additions & 0 deletions examples/federation/gateway.js
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}`)
Loading
Loading