Skip to content

Commit

Permalink
Add the ability to reference elements further up the call chain as na…
Browse files Browse the repository at this point in the history
…med parameters (#2988)

Query planning and composition work for adding @fromcontext and @context
along with bump federation to version 2.8 to accommodate.

---------

Co-authored-by: o0Ignition0o <jeremy.lempereur@gmail.com>
Co-authored-by: Sachin D. Shinde <sachin@apollographql.com>
  • Loading branch information
3 people committed May 14, 2024
1 parent 9b7c6ee commit c4744da
Show file tree
Hide file tree
Showing 32 changed files with 4,283 additions and 367 deletions.
25 changes: 25 additions & 0 deletions .changeset/hungry-llamas-remember.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
---
"@apollo/query-planner": minor
"@apollo/query-graphs": minor
"@apollo/composition": minor
"@apollo/federation-internals": minor
"@apollo/gateway": minor
---

Implement new directives to allow getting and setting context. This allows resolvers to reference and access data referenced by entities that exist in the GraphPath that was used to access the field. The following example demonstrates the ability to access the `prop` field within the Child resolver.

```graphql
type Query {
p: Parent!
}
type Parent @key(fields: "id") @context(name: "context") {
id: ID!
child: Child!
prop: String!
}
type Child @key(fields: "id") {
id: ID!
b: String!
field(a: String @fromContext(field: "$context { prop }")): Int!
}
```
1 change: 1 addition & 0 deletions .cspell/cspell-dict.txt
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,7 @@ referencer
relatity
Remaings
Remainings
Renamers
reoptimized
repeateable
reponse
Expand Down

0 comments on commit c4744da

Please sign in to comment.