-
Notifications
You must be signed in to change notification settings - Fork 192
feat: initial support for field resolvers in connect #2290
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Noroth
merged 41 commits into
main
from
ludwig/eng-6993-implement-field-resolver-for-graphql-operation
Nov 11, 2025
+12,302
−3,695
Merged
Changes from all commits
Commits
Show all changes
41 commits
Select commit
Hold shift + click to select a range
5fc73a3
feat: implement handling and validation for fields with arguments
Noroth 19b2ded
chore: format code
Noroth 62d8542
feat: add support for field resolvers in protographic
Noroth 0ab9b8a
add field resolvers to the demo
Noroth 6d68c30
feat: initial support for field resolvers
Noroth 47a6c0f
chore: update composition-go
Noroth c7f8524
chore: add export
Noroth d867ec1
chore: use extension in import
Noroth 91bb1b3
chore: regenerate test configs
Noroth 2682575
implement directivesRoot for requireFetchReasons
ysmolski e1e3c4b
chore: update directive name
Noroth c41534e
chore: update go mod for test
Noroth 11d0f3d
chore: fallback to empty list
Noroth 9c6d19a
chore: update test configs
Noroth 4cafba1
chore: handle snake_case for context fields
Noroth b6081e4
chore: update SDL rules
Noroth 16234ed
chore: include protographic in router ci
Noroth a5f7fc5
Merge branch 'main' of github.com:wundergraph/cosmo into ludwig/eng-6…
Noroth 1f3fdbf
chore: update composition
Noroth a92ba67
use temporary go-tools version
Noroth c43b00f
chore: update docstrings
Noroth 986381e
chore: more improvements
Noroth cb3f863
chore: improvements
Noroth 9e50102
chore: clean up
Aenimus 7a19f53
chore: use temporary commit
Noroth d3606c8
chore: detect nested cycle in references
Noroth 7c88361
chore: lint mimimi
Noroth ccffcc9
chore: remove protographic again
Noroth 261bcd7
chore: use proper naming
Noroth c320f6b
chore: update composition-go
Noroth ab7c5d4
chore: remove unused import
Noroth c3efe8f
chore: skip directive with config
Noroth 8e2793b
Merge branch 'main' of github.com:wundergraph/cosmo into ludwig/eng-6…
Noroth 3eaf12f
chore: temporary engine version
Noroth 754c4e6
chore: use values
Noroth b9fc1dd
chore: remove anonymous function
Noroth 3821ecb
chore: simplify
Noroth d770ea8
chore: improve loop
Noroth 491bb26
Merge branch 'main' into ludwig/eng-6993-implement-field-resolver-for…
Noroth 9ff5af9
chore: update engine version
Noroth de5639e
Merge branch 'main' into ludwig/eng-6993-implement-field-resolver-for…
Noroth File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
87 changes: 87 additions & 0 deletions
87
composition/tests/v1/directives/connect-configure-resolver.test.ts
This file contains hidden or 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 |
|---|---|---|
| @@ -0,0 +1,87 @@ | ||
| import { describe, expect, test } from 'vitest'; | ||
| import { | ||
| CONNECT_FIELD_RESOLVER, | ||
| CONTEXT, | ||
| invalidDirectiveError, | ||
| NormalizationFailure, | ||
| NormalizationSuccess, | ||
| normalizeSubgraph, | ||
| ROUTER_COMPATIBILITY_VERSION_ONE, | ||
| Subgraph, | ||
| undefinedRequiredArgumentsErrorMessage, | ||
| } from '../../../src'; | ||
| import { parse, printSchema } from 'graphql'; | ||
| import { | ||
| normalizeString, | ||
| normalizeSubgraphFailure, | ||
| normalizeSubgraphSuccess, | ||
| schemaToSortedNormalizedString, | ||
| } from '../../utils/utils'; | ||
| import { CONNECT_FIELD_RESOLVER_DIRECTIVE, OPENFED_FIELD_SET, SCHEMA_QUERY_DEFINITION } from '../utils/utils'; | ||
|
|
||
| describe('@connect__fieldResolver tests', () => { | ||
| test('that @connect__fieldResolver is automatically included in the subgraph schema if it is referenced', () => { | ||
| const { schema, warnings } = normalizeSubgraphSuccess( | ||
| subgraphWithConnectConfigureResolver, | ||
| ROUTER_COMPATIBILITY_VERSION_ONE, | ||
| ); | ||
| expect(warnings).toHaveLength(0); | ||
| expect(schemaToSortedNormalizedString(schema)).toBe( | ||
| normalizeString( | ||
| SCHEMA_QUERY_DEFINITION + | ||
| CONNECT_FIELD_RESOLVER_DIRECTIVE + | ||
| ` | ||
| type Foo { | ||
| bar(baz: String!): String @connect__fieldResolver(context: "id") | ||
| id: ID! | ||
| } | ||
|
|
||
| type Query { | ||
| foo: Foo! | ||
| } | ||
| ` + | ||
| OPENFED_FIELD_SET, | ||
| ), | ||
| ); | ||
| }); | ||
|
|
||
| test('that @connect__fieldResolver needs to have a context', () => { | ||
| const { errors } = normalizeSubgraphFailure( | ||
| subgraphWithConnectConfigureResolverWithoutContext, | ||
| ROUTER_COMPATIBILITY_VERSION_ONE, | ||
| ); | ||
|
|
||
| expect(errors).toHaveLength(1); | ||
| expect(errors[0]).toStrictEqual( | ||
| invalidDirectiveError(CONNECT_FIELD_RESOLVER, `Foo.bar`, `1st`, [ | ||
| undefinedRequiredArgumentsErrorMessage(CONNECT_FIELD_RESOLVER, [CONTEXT], []), | ||
| ]), | ||
| ); | ||
| }); | ||
| }); | ||
|
|
||
| const subgraphWithConnectConfigureResolver: Subgraph = { | ||
| name: 'connect-configure-resolver', | ||
| url: '', | ||
| definitions: parse(` | ||
| type Foo { | ||
| bar(baz: String!): String @connect__fieldResolver(context: "id") | ||
| id: ID! | ||
| } | ||
|
|
||
| type Query { | ||
| foo: Foo! | ||
| } | ||
| `), | ||
| }; | ||
|
|
||
| const subgraphWithConnectConfigureResolverWithoutContext: Subgraph = { | ||
| name: 'connect-configure-resolver-without-context', | ||
| url: '', | ||
| definitions: parse(` | ||
| type Foo { | ||
| bar(baz: String!): String @connect__fieldResolver | ||
| id: ID! | ||
| } | ||
| `), | ||
| }; |
This file contains hidden or 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
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.