router icon indicating copy to clipboard operation
router copied to clipboard

Use `SchemaTypeRef` instead of `Node<ObjectType>` in `ConnectedElement`

Open benjamn opened this issue 3 months ago • 3 comments

This PR represents a combination/cherry-picking of several commits from my abstract types PR https://github.com/apollographql/router/pull/8143 (which I am currently attempting to simplify for easier review).

A SchemaTypeRef is a reference to a &Schema as well as the &Name and &ExtendedType of some named type within the schema, all with the same 'schema lifetime. The SchemaTypeRef::new method returns an Option<SchemaTypeRef> to guarantee that SchemaTypeRef references are only created for actual schema types, so if you have a SchemaTypeRef you can be sure the type it represents exists in the schema.

Because SchemaTypeRef has access to the Schema (not just the individual element), it can perform operations that are aware of other types within the same schema, like finding all the implementing/member types of an interface or union.

Further, since SchemaTypeRef can represent any named type in the schema, not just ObjectType, these changes should lay some of the necessary groundwork for working with abstract types, where the type in question might be an InterfaceType or UnionType (not just ObjectType).

After some earlier attempts, I've decided it's important to use a type like SchemaTypeRef that still implements the Copy trait (by holding only references), rather than (say) ExtendedType (which must be Cloned), so we don't have to update all the data structures that assume they can implement Copy while using ConnectedElement.

benjamn avatar Nov 17 '25 22:11 benjamn

✅ Docs preview ready

The preview is ready to be viewed. View the preview

File Changes

0 new, 1 changed, 0 removed
* graphos/routing/(latest)/performance/caching/response-caching/observability.mdx

Build ID: 2e1e05ab187e73db7a37c745 Build Logs: View logs

URL: https://www.apollographql.com/docs/deploy-preview/2e1e05ab187e73db7a37c745

apollo-librarian[bot] avatar Nov 17 '25 22:11 apollo-librarian[bot]

@copilot I basically agree with everything @naomijub suggested above. Can you draft a commit that addresses everything unambiguous and a comment that explains anything you couldn't handle?

benjamn avatar Nov 25 '25 16:11 benjamn

@benjamn I've opened a new pull request, #8676, to work on those changes. Once the pull request is ready, I'll request review from you.

Copilot avatar Nov 25 '25 16:11 Copilot