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

Improve schema validation factory #638

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open

Improve schema validation factory #638

wants to merge 4 commits into from

Conversation

gnawf
Copy link
Collaborator

@gnawf gnawf commented Nov 27, 2024

No description provided.

@gnawf gnawf marked this pull request as draft November 27, 2024 22:54
Copy link

github-actions bot commented Nov 27, 2024

Test Results

  134 files  +1  134 suites  +1   56s ⏱️ -1s
  999 tests +1  934 ✅ +1  65 💤 ±0  0 ❌ ±0 
1 007 runs  +1  942 ✅ +1  65 💤 ±0  0 ❌ ±0 

Results for commit a19a800. ± Comparison against base commit bc72914.

This pull request removes 1 and adds 2 tests. Note that renamed tests count towards both.
graphql.nadel.validation.NadelVirtualTypeValidationTest ‑ can reference ()
graphql.nadel.validation.NadelValidationDefinitionsTest ‑ do not use parse definitions functions in validation()
graphql.nadel.validation.NadelVirtualTypeValidationTest ‑ can use original field output type in virtual type()

♻️ This comment has been updated with latest results.

@gnawf gnawf force-pushed the custom-hydration-directive-2 branch from b0cf2ca to a337f89 Compare December 2, 2024 00:04
@gnawf gnawf changed the base branch from custom-hydration-directive-2 to master December 2, 2024 03:37
@gnawf gnawf marked this pull request as ready for review December 2, 2024 03:38
import graphql.nadel.engine.util.unwrapAll
import graphql.schema.GraphQLType

class NadelAssignableTypeValidation internal constructor(
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

As I was moving NadelTypeWrappingValidation around I realised I could extract some duplicated code into here.

@Deprecated("Mistake to use this inside validation", level = DeprecationLevel.ERROR)
fun GraphQLFieldDefinition.hasHydratedDefinition(): Nothing {
throw UnsupportedOperationException()
}
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Didn't like this approach, moved this into a archunit test instead.

@@ -59,7 +62,7 @@ class NadelFieldValidation internal constructor(
overallField: GraphQLFieldDefinition,
): NadelSchemaValidationResult {
return if (isRenamed(parent, overallField)) {
renameValidation.validate(parent, overallField)
validateRename(parent, overallField)
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Extracted the one rename validation function to this class to avoid a cyclic dependency in NadelRenameValidation

* It checks whether the type name and type wrappings e.g. [graphql.schema.GraphQLNonNull] make sense.
*/
context(NadelValidationContext)
private fun isOutputTypeValid(
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Moved this to NadelAssignableTypeValidation

overallType: GraphQLInputType,
underlyingType: GraphQLInputType,
): Boolean {
val typeWrappingValid = typeWrappingValidation.isTypeWrappingValid(
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

All this deleted code was just moved to NadelAssignableTypeValidation.isInputTypeAssignable

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant