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

refactor: Cleanup SchemaProxy #132

Merged
merged 1 commit into from
Dec 17, 2024
Merged

Conversation

stuebingerb
Copy link
Owner

@stuebingerb stuebingerb commented Dec 11, 2024

SchemaProxy is (from my understanding) only a wrapper for schema introspection, and as such should not need to deal with Kotlin classes or offer execution options. This commit also removes some more unused code.

@stuebingerb
Copy link
Owner Author

Tests are running (and there are several related ones) but removing the LookupSchema interface required some changes in SchemaCompilation that might warrant a second look.

@@ -461,4 +453,10 @@ class SchemaCompilation(
transformation = transformation as Transformation<T, R>?
)
}

private fun typenameField(functionWrapper: FunctionWrapper<String>) = Field.Function(
Copy link
Owner Author

@stuebingerb stuebingerb Dec 11, 2024

Choose a reason for hiding this comment

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

This definition skips all stuff previously done in handleOperation but IMHO that stuff is not necessary for the __typename: We already know the return type and we know that there are no input values.

}, true))
)
val __typenameField = typenameField(FunctionWrapper.on({ value: Any ->
queryTypeProxies[value.javaClass.kotlin]?.name ?: error("No query type proxy found for $value")
Copy link
Owner Author

@stuebingerb stuebingerb Dec 11, 2024

Choose a reason for hiding this comment

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

typeByKClass is doing model.queryTypes[kClass] with queryTypes = queryTypeProxies + enums + scalars, so a bit different.

IMHO this is still fine as according to the spec the __typename is available "on any Object, Interface, or Union" - i.e. no enums or scalars.

@stuebingerb stuebingerb force-pushed the refactor/cleanup-schema-proxy branch 3 times, most recently from ff0d534 to 05fd701 Compare December 16, 2024 15:54
@stuebingerb stuebingerb changed the base branch from main to fix/fix-non-nullable-union-types December 16, 2024 15:55
@stuebingerb stuebingerb force-pushed the refactor/cleanup-schema-proxy branch from 05fd701 to 6f67c79 Compare December 16, 2024 15:55
@stuebingerb stuebingerb changed the base branch from fix/fix-non-nullable-union-types to main December 16, 2024 15:55
@stuebingerb stuebingerb force-pushed the refactor/cleanup-schema-proxy branch from 6f67c79 to a039cad Compare December 16, 2024 16:50
@stuebingerb stuebingerb changed the base branch from main to fix/fix-non-nullable-union-types December 16, 2024 16:50
@stuebingerb stuebingerb force-pushed the fix/fix-non-nullable-union-types branch from 3aed18f to fe52c50 Compare December 17, 2024 12:21
Base automatically changed from fix/fix-non-nullable-union-types to main December 17, 2024 12:38
`SchemaProxy` is (from my understanding) only a wrapper for schema
introspection, and as such should not need to deal with Kotlin classes
or offer execution options. This commit also removes some more unused
code.
@stuebingerb stuebingerb force-pushed the refactor/cleanup-schema-proxy branch from a039cad to 3b4af49 Compare December 17, 2024 12:39
@stuebingerb stuebingerb merged commit 7e6fc39 into main Dec 17, 2024
4 checks passed
@stuebingerb stuebingerb deleted the refactor/cleanup-schema-proxy branch December 17, 2024 13:10
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