-
Notifications
You must be signed in to change notification settings - Fork 2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2883 from apollographql/jackson/READMEs
First draft of readmes
- Loading branch information
Showing
2 changed files
with
69 additions
and
0 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 |
---|---|---|
@@ -1 +1,40 @@ | ||
# `Apollo Federation Utilities` | ||
|
||
This package provides utilities for creating GraphQL microservices, which can be combined into a single endpoint through tools like [Apollo Gateway](https://github.com/apollographql/apollo-server/tree/master/packages/apollo-gateway). | ||
|
||
For complete documentation, see the [Apollo Federation API reference](https://www.apollographql.com/docs/apollo-server/api/apollo-federation/). | ||
|
||
## Usage | ||
|
||
```js | ||
const { ApolloServer, gql } = require("apollo-server"); | ||
const { buildFederatedSchema } = require("@apollo/federation"); | ||
|
||
const typeDefs = gql` | ||
type Query { | ||
me: User | ||
} | ||
type User @key(fields: "id") { | ||
id: ID! | ||
username: String | ||
} | ||
`; | ||
|
||
const resolvers = { | ||
Query: { | ||
me() { | ||
return { id: "1", username: "@ava" } | ||
} | ||
}, | ||
User: { | ||
__resolveReference(user, { fetchUserById }){ | ||
return fetchUserById(user.id) | ||
} | ||
} | ||
}; | ||
|
||
const server = new ApolloServer({ | ||
schema: buildFederatedSchema([{ typeDefs, resolvers }]) | ||
}); | ||
``` |
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 |
---|---|---|
@@ -1 +1,31 @@ | ||
# Apollo Gateway | ||
|
||
This package provides utilities for combining multiple GraphQL microservices into a single GraphQL endpoint. | ||
|
||
Each microservice should implement the [federation schema specification](https://www.apollographql.com/docs/apollo-server/federation/federation-spec/). This can be done either through [Apollo Federation](https://github.com/apollographql/apollo-server/tree/master/packages/apollo-federation) or a variety of other open source products. | ||
|
||
For complete documentation, see the [Apollo Gateway API reference](https://www.apollographql.com/docs/apollo-server/api/apollo-gateway/). | ||
|
||
## Usage | ||
|
||
```js | ||
const { ApolloServer } = require("apollo-server"); | ||
const { ApolloGateway } = require("@apollo/gateway"); | ||
|
||
const gateway = new ApolloGateway({ | ||
serviceList: [ | ||
{ name: "accounts", url: "http://localhost:4001/graphql" }, | ||
// List of federation-capable GraphQL endpoints... | ||
] | ||
}); | ||
|
||
(async () => { | ||
const { schema, executor } = await gateway.load(); | ||
|
||
const server = new ApolloServer({ schema, executor }); | ||
|
||
server.listen().then(({ url }) => { | ||
console.log(`🚀 Server ready at ${url}`); | ||
}); | ||
})(); | ||
``` |