Apollo Connectors Changelog
Connectors 0.3 & Federation 2.12.0
Upgrade instructions
Upgrade local development environments for testing:
supergraph.yamlfiles should havefederation_versionset to=2.12.0or later.Rover should be v0.36.0 or later.
Update your deployed routers to support Connectors 0.3.
Update the Build pipeline in GraphOS Studio to v2.12.
Go to your graph's Settings page and click Update version to update your Federation version to 2.12.
Update your schemas to use Connectors v0.3:
GraphQL1extend schema 2 @link( 3 url: "https://specs.apollo.dev/connect/v0.3", 4 import: ["@source", "@connect"] 5 )
Learn more about Connectors version requirements.
New features
Environment variable access with $env
Access environment variables in your Connectors using the new $env variable. This is useful for API keys or other configuration values that you don't want to hard-code into your schema.
New array methods
Added new array manipulation methods:
find- Returns the first item in an array that matches the specified criteriafilter- Returns a new array containing all items that match the specified criteriaget- Returns the character at a specified index (for strings), item at a specified index (for arrays), or property with a specified name (for objects)
New logical operators
Added logical operators for conditional expressions:
ne- Not equal toin- Value is in the list of argumentscontains- Array contains the argument valuelte- Less than or equal togt- Greater thanlt- Less thangte- Greater than or equal toor- Logical ORnot- Inverts boolean valueeq- Equal toand- Logical AND
New math methods
Added mathematical operations:
mod- Modulo operation (remainder after division)sub- Subtractionadd- Additiondiv- Divisionmul- Multiplication
Type coercion methods
Added methods for type conversion:
parseInt- Converts a value to anInttoString- Converts a value to aString
Nullish coalescing operators
The new ?? and ?! operators enable providing default values when expressions evaluate to null or None:
??- Coalesces onnullorNone?!- Coalesces only onNone
1people: $(people ?? [])
2bOrDefault: $(b ?? "default")
3nullAllowed: $(null ?! "default")
4safeSlice: array->slice($args.sliceStart ?? 0, $args.sliceEnd ?? 10)Custom success handling with isSuccess
The new isSuccess argument for @source and @connect directives enables customizing how HTTP status codes are handled. By default, 20X responses map to data and other status codes map to errors. With isSuccess, you can customize this behavior using expressions that evaluate to a boolean.
1type Mutation {
2 createProduct: CreateProductResponse!
3 @connect(
4 http: { GET: "https://api.dev/endpoint-that-can-fail" }
5 isSuccess: "$(true)"
6 selection: """
7 product { id }
8 errors { message }
9 """
10 )
11}Router 2.3.0 & Composition 2.11.0
Upgrade instructions
Upgrade local development environments for testing:
supergraph.yamlfiles should havefederation_versionset to=2.11.0or later.Rover should be v0.30.0 or later.
Update your deployed routers to v2.3.0.
Update the Build pipeline in GraphOS Studio to v2.11.
Go to your graph's Settings page and click Update version to update your Federation version to 2.11.
Learn more about Connectors version requirements.
New features
Resolve entities using Connectors on types
You can now add @connect directly on types instead of adding a Query or Mutation field.
type Price @key(fields: "id") {
id: ID!
active: Boolean
currency: String
unitAmount: Float
}
type Query {
price(id: ID!): Price
@connect(
source: "ecomm"
http: { GET: "/prices/{$args.id}"}
selection: """
id
active
currency
unitAmount: unit_amount
"""
entity: true
)
@inaccessible
}type Price @key(fields: "id")
@connect(
source: "ecomm"
http: { GET: "/products/{$this.id}/price" }
selection: """
id
active
currency
unitAmount
}
"""
){
id: ID!
active: Boolean
currency: String
unitAmount: Float
}This eliminates the need to include entity: true when resolving entities. See Where to use @connect for details on when to use @connect on types and fields.
Batch requests with $batch
The new $batch variable allows you to address the N+1 problem by batching requests to REST batch endpoints. This helps optimize your API calls by reducing the number of network requests. Learn more in the batch request documentation.
joinNotNull method
The new ->joinNotNull method allows you to join a list of strings with a comma or other separators. It ignores any null values in the list.
1type Query {
2 products(filterName: String, filterValue: [String]): [Product]
3 @connect(
4 source: "myApi"
5 http: {
6 GET: "/products?{$args.filterName}={$args.filterValue->joinNotNull(',')}"
7 }
8 selection: "id name reviews { id }"
9 )
10}This is particularly useful for passing lists of IDs to a REST endpoint for batch requests.
1type Review
2 @connect(
3 source: "myApi"
4 http: { GET: "/reviews?ids={$batch.id->joinNotNull(',')}" }
5 selection: "id text rating"
6 ) {
7 id: ID!
8 text: String!
9 rating: Int!
10}Advanced request URL building
Building URLs is now more flexible with two new options:
The
http.queryParamsargument supports repeating and nullable query parametersThe
http.pathargument enables building dynamic URL path segments with arrays of values as described in the dynamic path segments documentation.
Request and response header access
New variables $request.headers and $response.headers are now available to access request and response headers when building request URLs, bodies, and in selection mapping. This enables more sophisticated data transformation based on header values. See the variables reference for usage details.
Non-JSON response support
Connectors now supports mapping against endpoints that return non-JSON content types, opening up text-based responses, empty responses, and more. See the response handling documentation for details.
Customized error handling
Customize the message and extensions of the GraphQL response when an HTTP endpoint returns a non-200 status. This gives you greater control over error presentation to clients. Learn more in the error handling documentation.
Router 2.2.0
New features
YAML-based header propagation
Connectors now support the router's header propagation features. See the Connectors traffic shaping documentation for configuration examples.
Router 2.1.2 & Composition 2.10.2
Bug fixes
Fixed a bug that dropped
@context/@fromContextdirectives from the supergraph schema when any subgraph schema uses Connectors. The context pattern is still available only for subgraph schemas that don't use Connectors.Fixed a bug relating to how Connectors methods work. The fix standardizes
->methodbehavior to apply to the full value of an expression, not each item, when the preceding expression returns an array. For example, prior to this change, the expression$.id->jsonStringifyresulted in["1","2","3"], with each item individually stringified. After the fix, the result is'["1","2","3"]', with the entire array stringified.
Router 2.1.0
New features
Traffic shaping support
Connectors now support the router's traffic shaping features. See the Connectors traffic shaping documentation for configuration examples.
TLS support
Connectors now support the router's TLS features to authenticate and encrypt communications. See the Connectors traffic shaping documentation for configuration examples.
2025-02-18
Router 2.0.0 & Composition 2.10.0
New features
General availability of Apollo Connectors
Apollo Connectors is now generally available.
Migrating from Apollo Connectors preview releases
You must migrate your router Connectors configuration to the GA format once you update your router to v2.0.0. When you update to v2.0.0, configurations from preview releases no longer work.
The key changes between preview and GA versions:
The top-level
preview-connectorsconfiguration has been renamed toconnectors.Configuration that was previously under
subgraphshas now moved tosources.Each Connector source is now configured under an entry combining the subgraph name and source name, separated by a
.—for example,subgraph_name.source_name.Any
$configvariables should now be placed under their corresponding source configuration.
For example, given the following preview configuration:
1preview_connectors:
2 # This applies globally to all Connectors
3 max_requests_per_operation_per_source: 100
4 subgraphs:
5 example: # The name of the subgraph
6 $config:
7 my.config.value: true # Applies to all sources in this subgraph
8 sources:
9 v1: # Refers to @source(name: "v1")
10 # These configurations apply to Connectors with the "endpoint1" source in the "subgraph1" subgraph
11 override_url: 'https://localhost:5000'
12 max_requests_per_operation: 50
13 v2: # Refers to @source(name: "v2")
14 # These configurations apply to Connectors with the "endpoint2" source in the "subgraph1" subgraph
15 max_requests_per_operation: 100The GA configuration would look like this:
1connectors:
2 # This applies globally to all Connectors
3 max_requests_per_operation_per_source: 100
4 sources:
5 subgraph1.endpoint1: # subgraph.source
6 # These configurations apply to Connectors with the "endpoint1" source in the "subgraph1" subgraph
7 override_url: 'https://localhost:5000'
8 max_requests_per_operation: 50
9 $config:
10 my.config.value: true # Applies to the "v1" source
11 subgraph1.endpoint2: # subgraph.source
12 # These configurations apply to Connectors with the "endpoint2" source in the "subgraph1" subgraph
13 max_requests_per_operation: 25
14 another.config.value: true # Applies to the "v2" sourceDeprecated preview releases
Deprecated preview releases
2025-02-06
Router 2.0.0-preview.6 & Composition 2.10.0-preview.6Fixes
- Improve composition performance
- Provide a clearer error when the version of Connectors is incorrect in a
@linkdirective
2025-01-31
Router 2.0.0-preview.5 & Composition 2.10.0-preview.5Breaking changes
- When the
->mapmethod is applied to a non-list value, the result is now a list. For example$(1)->map(@)results in[1].
New features
- The Connectors Mapping Playground is officially available. Use it to experiment and troubleshoot mapping expressions.
New validations
- Validations on the
http.bodynow catch more types of errors. For example, validations now flag selections that don't come from a variable (myFieldinstead of$this.myField).
Fixes
- The router no longer tries to parse an empty API response. If your API responds with nothing, you can use literal values like
success: $(true)to map to your schema. - The
@costand@listSizedirectives are preserved to support Demand Control. - Types marked with
@externalare handled correctly.
2025-01-15
Router 2.0.0-preview.4 & Composition 2.10.0-preview.4Breaking changes
- Adding a
@keydirective to a type signals to the query planner that this subgraph implements an entity resolver for that type. When using Connectors, you can accomplish this by adding anentity: trueargument to the Connector.- If you see an error like
Entity resolution for @key(fields: "id") on Product is not implemented by a connector, it means you need to either add anentity: trueConnector or addresolvable: falseto the@keydirective. - See the Rules for
entity: truefor more details.
- If you see an error like
- Header expressions now match the behavior of URI templates, so arrays and objects are no longer allowed. You can restore the old behavior using
->jsonStringifyor explore other methods.
New features
- Includes all changes from router v1.59.1.
- Better type inference and validations for selection mappings.
- The
jsonStringifyvalue transformation is available to JSON stringify any value. - Expressions within URIs and headers now support the full power of mapping expressions.
- Within the dynamic
{ }pieces of a URI or header, you can apply the same transformations allowed withinselectionandbody. - The expression's result must be a simple scalar value.
- Arrays and objects can't be serialized into URI or header values.
- Within the dynamic
2024-12-09
Router 2.0.0-preview.3 & Composition 2.10.0-preview.3Breaking changes to URI templates
- Arrays and objects can no longer be used in URI templates. If you need to convert complex types into URI parameters, contact Apollo to request new functionality and how you'd like them to be serialized.
nullvalues will now render in URIs as empty strings ("") instead of"null".- If an expression within the key or value of a query parameter is missing, it will now be rendered as an empty string instead of omitting the query parameter entirely.
- Missing values in path parameters will now render as empty strings instead of returning errors.
New validations
- Certain headers are already restricted by the router. Composition will now emit an error if one of these is set in
@sourceor@connect. - Variables used within headers are now validated at composition time.
New features
- Includes all changes from router v1.58.1.
$argsand$thisvariables can be used in HTTP headers for Connectors.- The
$contextvariable is available in selection mapping, as well as URLs, headers, and body mappings. - The
$statusvariable, representing the HTTP Status Code (200, 404, etc.) is available in selection mapping.
Bug fixes
- Fixed a couple of edge cases where composition would fail. A small fraction of supergraph still do not compose.
- Connectors debugging information is now included for multipart responses, like when
@deferis used. - Composition will no longer emit "unused field" errors if another error (such as a selection parse error) happens first. This makes it easier to spot the most important errors.
- Escape sequences in selection and body strings are handled correctly.
2024-11-08
Router 2.0.0-preview.1 & Composition 2.10.0-preview.2New features
- Includes all changes from Router 1.57.0.
- Router telemetry can now be configured for Connectors.
- Connectors can now invoke AWS HTTP APIs using SigV4.
- The
content-lengthheader is automatically set onPOST,PATCH, andPUTrequests. - Error messages for parsing errors in
@connect(selection:)and@connect(http: { body: })are more informative. - Using coprocessors to fetch authentication tokens is now easier. See authentication with coprocessors.
Bug fixes
- Fixed a bug where
$this.siblingField.nestedFieldfailed to compose. - A non-JSON response no longer causes all responses to fail.
2024-10-01
Router 2.0.0-preview.0 & Composition 2.10.0-preview.0Selection mapping enhancements
- To distinguish a path consisting of a single key from a field name,
you should now use
$.keyinstead of.key. The.keysyntax is now forbidden since it can accidentally parse as a continuation of a previous selection, whereas$.keyis unambiguous. - Multiple deeply nested properties can now be flattened into the same output
object alongside shallower properties:This selection produces an object withGraphQL
1id 2model 3choices->first.message { role content }id,model,role, andcontentproperties, all at the same level.Previously, to achieve the same output, it was necessary to repeat thechoices->first.messagepath multiple times:GraphQL1id 2model 3role: choices->first.message.role 4content: choices->first.message.content
Improvements
- Includes all changes from router release 1.56.
2024-09-23
Router 2.0.0-alpha.7 & Composition 2.10.0-alpha.4Selection mapping enhancements
- Support for value transforms in selection mapping.
- Support for literal values in selection mapping.
New validations
- URL template arguments are now validated and must correspond to existing fields (
$this) or arguments ($args). entity: trueConnectors have several new validations, including enforcing that arguments match entity fields.
2024-09-11
Router 2.0.0-alpha.6 & Composition 2.10.0-alpha.3New validations
- Require that all fields are resolvable through a Connector.
New features
- Connectors now obey the
include_subgraph_errorsconfiguration.
Improvements
- Includes all changes from router release 1.54.
- When running the router in development mode, the local Sandbox will have the Connectors debug panel enabled by default.
2024-09-06
Router 2.0.0-alpha.5 & Composition 2.10.0-alpha.2New validations
- Require that every field of an object is included in at least one
selection. - When using Connectors, require that fields with arguments use a
@connectdirective.
New features
- URL-encoded forms are now supported in
bodyparameters.
Improvements
- Includes all changes from router release 1.52.1.
- Includes all changes from router release 1.53.0.
- Includes all changes from federation composition release 2.9.0.
- Better detect circular references in Connector selections.
2024-08-20
Router 2.0.0-alpha.3 & Composition 2.10.0-alpha.0New validations
New errors will be caught during composition, which may cause previously successful compositions to fail:- Referring to a field name within
selectionwhich doesn't exist.
Improvements
- Fully support
$thisand$argsinhttp.body. - Allow subgraph names which are not GraphQL identifiers, for example,
my-subgraph. - Allow
$configvalues in headers. - Ability to set request limits for Connectors.