Skip to content
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

ISSUE-1566: Relax federated type validation rules #1571

Merged
merged 5 commits into from
Oct 12, 2022

Conversation

hchen
Copy link
Contributor

@hchen hchen commented Oct 5, 2022

📝 Description

Relax federated type validation rules

  • allow base type to have fields with @external directive
  • allow base type to have fields with @requires directive
  • allow base type to have fields with @requires directive referring to fields with @external directive

🔗 Related Issues

#1566

@hchen hchen changed the title Issue 1566 ISSUE-1566: Relax federated type validation rules Oct 5, 2022
@samuelAndalon samuelAndalon added module: generator Issue affects the schema generator and federation code changes: patch Changes require a patch version labels Oct 6, 2022
@@ -128,7 +129,7 @@ class FederatedKeyDirectiveIT {
assertEquals(expected, exception.message)
}

@Test
@Disabled("This is a valid case according to Federation 2 spec")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

instead of disabling this test, this code (and referenced sample project) should be deleted

@@ -70,7 +71,7 @@ class FederatedRequiresDirectiveIT {
assertEquals(expected, exception.message)
}

@Test
@Disabled("this is a valid use case according to Federation 2 spec")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

instead of disabling this test, this code (and referenced sample project) should be deleted

errors.addAll(validateDirective("$validatedType.${validatedField.name}", REQUIRES_DIRECTIVE_NAME, validatedField.allAppliedDirectivesByName, fieldMap, extendedType))
} else {
errors.add("base $validatedType type has fields marked with @requires directive, validatedField=${validatedField.name}")
return validateDirective("$validatedType.${validatedField.name}", REQUIRES_DIRECTIVE_NAME, validatedField.allAppliedDirectivesByName, fieldMap, extendedType)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this validation should be applied for both base and extended type -> it doesn't make sense to keep this file anymore, move this validateDirective call directly to FederatedSchemaValidator

@@ -225,7 +226,7 @@ class FederatedSchemaValidatorTest {
* }
*/
@Test
fun `validate local GraphQLObjectType with valid key directive and field with invalid external directive`() {
fun `validate local GraphQLObjectType with valid key directive and field with external directive`() {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lets just drop this test

@@ -45,7 +45,7 @@ class ValidateRequiresDirectiveKtTest {
* }
*/
@Test
fun `Verify non extended types and non requires fields returns an error`() {
fun `Verify non extended types and non requires fields returns no error`() {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i think those tests should be dropped

Copy link
Collaborator

@dariuszkuc dariuszkuc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

see comments

@hchen
Copy link
Contributor Author

hchen commented Oct 12, 2022

retest

@dariuszkuc dariuszkuc merged commit 5974d8b into ExpediaGroup:master Oct 12, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
changes: patch Changes require a patch version module: generator Issue affects the schema generator and federation code
Development

Successfully merging this pull request may close these issues.

3 participants