Skip to content

Commit

Permalink
Merge branch 'main' into trevor/min-spec-versions-test
Browse files Browse the repository at this point in the history
  • Loading branch information
trevor-scheer authored Aug 7, 2024
2 parents 3a5d690 + cae9be3 commit cb8d65b
Show file tree
Hide file tree
Showing 84 changed files with 3,713 additions and 3,023 deletions.
2 changes: 1 addition & 1 deletion .cspell/cspell.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,6 @@ overrides:
- "\\]\\([^)]+\\)"
- "youTubeID=.+/>"
# Ignore user and repo names in GitHub links to supported subgraph libraries.
- filename: '**/supported-subgraphs.md'
- filename: '**/compatible-subgraphs.md'
ignoreRegExpList:
- "Github: <a .+</a>"
15 changes: 11 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@

[![CircleCI](https://circleci.com/gh/apollographql/federation/tree/main.svg?style=shield)](https://circleci.com/gh/apollographql/federation/tree/main) [![Netlify Status](https://api.netlify.com/api/v1/badges/3a012f93-2d02-41f7-bb2b-848cf005b831/deploy-status)](https://app.netlify.com/sites/apollo-federation-docs/deploys)

---

**Announcement:**
Join 1000+ engineers at GraphQL Summit for talks, workshops, and office hours, Oct 8-10 in NYC. [Get your pass here ->](https://summit.graphql.com/?utm_campaign=github_federation_readme)

---

# Apollo Federation

Apollo Federation is an architecture for declaratively composing APIs into a unified graph. Each team can own their slice of the graph independently, empowering them to deliver autonomously and incrementally.
Expand Down Expand Up @@ -29,11 +36,11 @@ If you ever have any problems, questions, or ideas, the maintainers of this proj

## Who is Apollo?

[Apollo](https://apollographql.com/) builds open-source software and a graph platform to unify GraphQL across your apps and services. We help you ship faster with:
[Apollo](https://apollographql.com/) builds open-source tools and commercial services to make application development easier, better, and accessible to more people. We help you ship faster with:

* [GraphOS](https://www.apollographql.com/docs/graphos) – A free, end-to-end platform for managing your GraphQL lifecycle. Track your GraphQL schemas in a hosted registry to create a source of truth for everything in your graph. GraphOS provides an IDE (Apollo Explorer) so you can explore data, collaborate on queries, observe usage, and safely make schema changes.
* [Apollo Federation](https://www.apollographql.com/apollo-federation) – The industry-standard open architecture for building a distributed graph. Use Apollo’s to compose a unified graph from multiple subgraphs, determine a query plan, and route requests across your services.
* [Apollo Client](https://www.apollographql.com/apollo-client/) – The most popular GraphQL client for the web. Apollo also builds and maintains [Apollo iOS](https://github.com/apollographql/apollo-ios) and [Apollo Android](https://github.com/apollographql/apollo-android).
* [GraphOS](https://www.apollographql.com/graphos) - The platform for building, managing, and scaling a supergraph: a unified network of your organization's microservices and their data sources—all composed into a single distributed API.
* [Apollo Federation](https://www.apollographql.com/federation) – The industry-standard open architecture for building a distributed graph. Use Apollo’s gateway to compose a unified graph from multiple subgraphs, determine a query plan, and route requests across your services.
* [Apollo Client](https://github.com/apollographql/apollo-client) – The most popular GraphQL client for the web. Apollo also builds and maintains [Apollo iOS](https://github.com/apollographql/apollo-ios) and [Apollo Kotlin](https://github.com/apollographql/apollo-kotlin).
* [Apollo Server](https://www.apollographql.com/docs/apollo-server/) – A production-ready JavaScript GraphQL server that connects to any microservice, API, or database. Compatible with all popular JavaScript frameworks and deployable in serverless environments.

## Learn how to build with Apollo
Expand Down
78 changes: 78 additions & 0 deletions composition-js/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,83 @@
# CHANGELOG for `@apollo/composition`

## 2.8.4

### Patch Changes

- When doing interface type intersection detection, allow @interfaceObject to stand in for any type ([#3087](https://github.com/apollographql/federation/pull/3087))

- Updated dependencies [[`5f4bb160d024678d6facd471c43c8ec61c86e701`](https://github.com/apollographql/federation/commit/5f4bb160d024678d6facd471c43c8ec61c86e701), [`672aca7cbeb0a6a38586357a4e154f2dd91caa0c`](https://github.com/apollographql/federation/commit/672aca7cbeb0a6a38586357a4e154f2dd91caa0c)]:
- @apollo/federation-internals@2.8.4
- @apollo/query-graphs@2.8.4

## 2.8.3

### Patch Changes

- Error messages are now lazily evaluated for satisfiability validations. ([#3068](https://github.com/apollographql/federation/pull/3068))

- Query graph caches now use maps instead of sparsely-populated arrays for per-subgraph data. ([#3066](https://github.com/apollographql/federation/pull/3066))

- Add a fast path to skip override validation for fields without any subgraph `@override`s. ([#3070](https://github.com/apollographql/federation/pull/3070))

- Type merging now uses maps instead of sparsely-populated arrays for per-subgraph data. ([#3069](https://github.com/apollographql/federation/pull/3069))

- Stop duplicating hints for inconsistent value type fields per subgraph. ([#3071](https://github.com/apollographql/federation/pull/3071))

- Fix logic to compute missing subgraphs when generating composition hints/errors ([#3076](https://github.com/apollographql/federation/pull/3076))

- Use sets instead of arrays for tracking schema type/directive referencers. ([#3067](https://github.com/apollographql/federation/pull/3067))

- Updated dependencies [[`38debcf2f9af1a719bd1c8acbd9335efa8427ddb`](https://github.com/apollographql/federation/commit/38debcf2f9af1a719bd1c8acbd9335efa8427ddb), [`50d648ccffb05591878de75dc5522914ed48698f`](https://github.com/apollographql/federation/commit/50d648ccffb05591878de75dc5522914ed48698f), [`860aace9904e787f9bf05aad94be5b5920f10543`](https://github.com/apollographql/federation/commit/860aace9904e787f9bf05aad94be5b5920f10543), [`f753d55e9a49d11389ee4f8d7976533447e95ede`](https://github.com/apollographql/federation/commit/f753d55e9a49d11389ee4f8d7976533447e95ede), [`3af790517d662f3bec9064c0bf243014c579e9cd`](https://github.com/apollographql/federation/commit/3af790517d662f3bec9064c0bf243014c579e9cd)]:
- @apollo/query-graphs@2.8.3
- @apollo/federation-internals@2.8.3

## 2.8.3-beta.2

### Patch Changes

- Updated dependencies [[`50d648ccffb05591878de75dc5522914ed48698f`](https://github.com/apollographql/federation/commit/50d648ccffb05591878de75dc5522914ed48698f)]:
- @apollo/federation-internals@2.8.3-beta.2
- @apollo/query-graphs@2.8.3-beta.2

## 2.8.3-beta.1

### Patch Changes

- Fix logic to compute missing subgraphs when generating composition hints/errors ([#3076](https://github.com/apollographql/federation/pull/3076))

- Updated dependencies []:
- @apollo/federation-internals@2.8.3-beta.1
- @apollo/query-graphs@2.8.3-beta.1

## 2.8.3-beta.0

### Patch Changes

- Error messages are now lazily evaluated for satisfiability validations. ([#3068](https://github.com/apollographql/federation/pull/3068))

- Query graph caches now use maps instead of sparsely-populated arrays for per-subgraph data. ([#3066](https://github.com/apollographql/federation/pull/3066))

- Add a fast path to skip override validation for fields without any subgraph `@override`s. ([#3070](https://github.com/apollographql/federation/pull/3070))

- Type merging now uses maps instead of sparsely-populated arrays for per-subgraph data. ([#3069](https://github.com/apollographql/federation/pull/3069))

- Stop duplicating hints for inconsistent value type fields per subgraph. ([#3071](https://github.com/apollographql/federation/pull/3071))

- Use sets instead of arrays for tracking schema type/directive referencers. ([#3067](https://github.com/apollographql/federation/pull/3067))

- Updated dependencies [[`38debcf2f9af1a719bd1c8acbd9335efa8427ddb`](https://github.com/apollographql/federation/commit/38debcf2f9af1a719bd1c8acbd9335efa8427ddb), [`860aace9904e787f9bf05aad94be5b5920f10543`](https://github.com/apollographql/federation/commit/860aace9904e787f9bf05aad94be5b5920f10543), [`f753d55e9a49d11389ee4f8d7976533447e95ede`](https://github.com/apollographql/federation/commit/f753d55e9a49d11389ee4f8d7976533447e95ede), [`3af790517d662f3bec9064c0bf243014c579e9cd`](https://github.com/apollographql/federation/commit/3af790517d662f3bec9064c0bf243014c579e9cd)]:
- @apollo/query-graphs@2.8.3-beta.0
- @apollo/federation-internals@2.8.3-beta.0

## 2.8.2

### Patch Changes

- Updated dependencies [[`b2e5ab66f84688ec304cfcf2c6f749c86aded549`](https://github.com/apollographql/federation/commit/b2e5ab66f84688ec304cfcf2c6f749c86aded549)]:
- @apollo/federation-internals@2.8.2
- @apollo/query-graphs@2.8.2

## 2.8.1

### Patch Changes
Expand Down
6 changes: 3 additions & 3 deletions composition-js/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@apollo/composition",
"version": "2.8.1",
"version": "2.8.4",
"description": "Apollo Federation composition utilities",
"main": "dist/index.js",
"types": "dist/index.d.ts",
Expand All @@ -27,8 +27,8 @@
"access": "public"
},
"dependencies": {
"@apollo/federation-internals": "2.8.1",
"@apollo/query-graphs": "2.8.1"
"@apollo/federation-internals": "2.8.4",
"@apollo/query-graphs": "2.8.4"
},
"peerDependencies": {
"graphql": "^16.5.0"
Expand Down
41 changes: 41 additions & 0 deletions composition-js/src/__tests__/compose.setContext.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1331,4 +1331,45 @@ describe("setContext tests", () => {
'[Subgraph1] @fromContext argument cannot be used on a field implementing an interface field "I.field".'
);
});

test("invalid context name shouldn't throw", () => {
const subgraph1 = {
name: "Subgraph1",
utl: "https://Subgraph1",
typeDefs: gql`
type Query {
t: T!
}
type T @key(fields: "id") @context(name: "") {
id: ID!
u: U!
prop: String!
}
type U @key(fields: "id") {
id: ID!
field(a: String): Int!
}
`,
};

const subgraph2 = {
name: "Subgraph2",
utl: "https://Subgraph2",
typeDefs: gql`
type Query {
a: Int!
}
type U @key(fields: "id") {
id: ID!
}
`,
};

const result = composeAsFed2Subgraphs([subgraph1, subgraph2]);
expect(result.schema).toBeUndefined();
expect(result.errors?.length).toBe(1);
expect(result.errors?.[0].message).toBe(
'[Subgraph1] Context name "" is invalid. It should have only alphanumeric characters.'
);
});
});
69 changes: 69 additions & 0 deletions composition-js/src/__tests__/compose.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5257,4 +5257,73 @@ describe('@source* directives', () => {
);
});
});

it('fed-354 repro @interfaceObject failure', () => {
const subgraph1 = {
name: 'Subgraph1',
url: 'https://Subgraph1',
typeDefs: gql`
type Query {
error_query: TicketField!
}
type User @interfaceObject @key(fields: "id") {
id: ID!
}
interface TicketField {
id: ID!
createdBy: User
}
type TextTicketField implements TicketField @key(fields: "id") @shareable {
id: ID!
createdBy: User
}
`
};

const subgraph2 = {
name: 'Subgraph2',
url: 'https://Subgraph2',
typeDefs: gql`
interface Ticket @key(fields : "id", resolvable : true) {
id: ID!
}
interface User @key(fields : "id", resolvable : true) {
id: ID!
requestedTickets: [Ticket!]!
}
interface TicketField {
createdBy: User
id: ID!
}
type TextTicketField implements TicketField @shareable {
createdBy: User
id: ID!
}
type Customer implements User @key(fields : "id", resolvable : true) @shareable {
id: ID!
requestedTickets: [Ticket!]!
}
type Agent implements User @key(fields : "id", resolvable : true) @shareable {
id: ID!
requestedTickets: [Ticket!]!
}
type Question implements Ticket @key(fields : "id", resolvable : true) {
fields: [TicketField!]!
id: ID!
}
`
};

const result = composeAsFed2Subgraphs([subgraph1, subgraph2]);
assertCompositionSuccess(result);
});
});
5 changes: 3 additions & 2 deletions composition-js/src/composeDirectiveManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import {
import { GraphQLError } from 'graphql';
import { CompositionHint, HINTS } from './hints';
import { MismatchReporter } from './merging/reporter';
import { sourcesFromArray } from './merging';

/**
* Return true if the directive from the same core feature has a different name in the subgraph
Expand Down Expand Up @@ -367,7 +368,7 @@ export class ComposeDirectiveManager {
this.mismatchReporter.reportMismatchErrorWithoutSupergraph(
ERRORS.DIRECTIVE_COMPOSITION_ERROR,
'Composed directive is not named consistently in all subgraphs',
this.subgraphs.values()
sourcesFromArray(this.subgraphs.values()
.map(sg => {
const item = items.find(item => sg.name === item.sgName);
return item ? {
Expand All @@ -384,7 +385,7 @@ export class ComposeDirectiveManager {
sourceAST,
item: val.item,
} : undefined;
}),
})),
(elt) => elt ? `"@${elt.item.directiveNameAs}"` : undefined
);
}
Expand Down
2 changes: 1 addition & 1 deletion composition-js/src/merging/coreDirectiveCollector.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export function collectCoreDirectivesToCompose(
const source = features.sourceFeature(directive);
// We ignore directives that are not "core" ones, or the ones that are defined but unused (note that this
// happen to ignore execution directives as a by-product)
if (!source || directive.applications().length === 0) {
if (!source || directive.applications().size === 0) {
continue;
}

Expand Down
Loading

0 comments on commit cb8d65b

Please sign in to comment.