Skip to content

Allows creating mock schemas where there are default values on custom schemas #4039

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
merged 1 commit into from
Jul 4, 2025

Conversation

bbakerman
Copy link
Member

If a schema has a default value on a custom scalar then the current MockWiringFactory will not fake it out well enough to create the schema

You get

java.lang.UnsupportedOperationException: Not implemented...this is only a mocked wiring

	at graphql.schema.idl.MockedWiringFactory$1.parseLiteral(MockedWiringFactory.java:72)
	at graphql.schema.Coercing.parseLiteral(Coercing.java:176)
	at graphql.schema.Coercing.parseLiteral(Coercing.java:205)
	at graphql.validation.ValidationUtil.parseLiteral(ValidationUtil.java:128)
	at graphql.validation.ValidationUtil.isValidLiteralValue(ValidationUtil.java:100)
	at graphql.schema.validation.DefaultValuesAreValid.visitGraphQLArgument(DefaultValuesAreValid.java:70)
	at graphql.schema.GraphQLArgument.accept(GraphQLArgument.java:301)
	at graphql.schema.SchemaTraverser$TraverserDelegateListVisitor.enter(SchemaTraverser.java:136)
	at graphql.util.Traverser.traverse(Traverser.java:144)
	at graphql.schema.SchemaTraverser.depthFirstFullSchema(SchemaTraverser.java:73)
	at graphql.schema.validation.SchemaValidator.validateSchema(SchemaValidator.java:41)

This changes it so it returns a value from the literal. Its still not an executable schema (there is no true data fetchers or type resolves) but the schema will be created ok

@bbakerman bbakerman added this to the 25.x breaking changes milestone Jul 4, 2025
return false;
}
return true;
return !ScalarInfo.isGraphqlSpecifiedScalar(environment.getScalarTypeDefinition().getName());
Copy link
Member Author

Choose a reason for hiding this comment

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

simplified

Copy link
Contributor

github-actions bot commented Jul 4, 2025

Test Results

  319 files    319 suites   2m 47s ⏱️
4 892 tests 4 882 ✅ 10 💤 0 ❌
4 981 runs  4 971 ✅ 10 💤 0 ❌

Results for commit c000df7.

@bbakerman bbakerman merged commit 28197a8 into master Jul 4, 2025
2 checks passed
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.

2 participants