Skip to content

Commit

Permalink
tidy up static args code
Browse files Browse the repository at this point in the history
  • Loading branch information
sbarker2 committed Sep 14, 2023
1 parent 181f1c4 commit 9a58595
Show file tree
Hide file tree
Showing 7 changed files with 10 additions and 34 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ private class Factory(
when (it.valueSource) {
is NadelHydrationActorInputDef.ValueSource.ArgumentValue -> null
is FieldResultValue -> it.valueSource.queryPathToField
is NadelHydrationActorInputDef.ValueSource.StaticValue -> null //check this (but should be right as only need fields for FieldResultValue ($source)
is NadelHydrationActorInputDef.ValueSource.StaticValue -> null
}
},
)
Expand Down Expand Up @@ -361,7 +361,7 @@ private class Factory(
when (val hydrationValueSource: NadelHydrationActorInputDef.ValueSource = it.valueSource) {
is NadelHydrationActorInputDef.ValueSource.ArgumentValue -> emptyList()
is FieldResultValue -> selectSourceFieldQueryPaths(hydrationValueSource)
is NadelHydrationActorInputDef.ValueSource.StaticValue -> emptyList() //check this (but should be right as only need fields for FieldResultValue ($source)
is NadelHydrationActorInputDef.ValueSource.StaticValue -> emptyList()
}
}).toSet()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ data class NadelHydrationActorInputDef(
* }
* ```
*/
data class FieldResultValue( // $source
data class FieldResultValue(
val queryPathToField: NadelQueryPath,
val fieldDefinition: GraphQLFieldDefinition,
) : ValueSource()
Expand All @@ -40,7 +40,7 @@ data class NadelHydrationActorInputDef(
* }
* ```
*/
data class ArgumentValue( // $args
data class ArgumentValue(
val argumentName: String,
val argumentDefinition: GraphQLArgument,
val defaultValue: NormalizedInputValue?,
Expand Down
2 changes: 1 addition & 1 deletion lib/src/main/java/graphql/nadel/schema/NadelDirectives.kt
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,7 @@ object NadelDirectives {
}
}

private fun createRemoteArgumentSource(value: Value<*>): RemoteArgumentSource { //needs to be graphql.language "Value"
private fun createRemoteArgumentSource(value: Value<*>): RemoteArgumentSource {
if (value is StringValue) {
val values = listFromDottedString(value.value)
return when (values.first()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,9 @@ import graphql.nadel.validation.util.NadelSchemaUtil.getHydrations
import graphql.nadel.validation.util.NadelSchemaUtil.hasRename
import graphql.schema.GraphQLFieldDefinition
import graphql.schema.GraphQLFieldsContainer
import graphql.schema.GraphQLInputType
import graphql.schema.GraphQLInterfaceType
import graphql.schema.GraphQLNamedOutputType
import graphql.schema.GraphQLSchema
import graphql.schema.GraphQLType
import graphql.schema.GraphQLUnionType

internal class NadelHydrationValidation(
Expand Down Expand Up @@ -217,9 +215,7 @@ internal class NadelHydrationValidation(
MissingHydrationFieldValueSource(parent, overallField, remoteArgSource)
} else {
// TODO: check argument type is correct
val fieldOutputType = field.type
hydrationArgTypesMatch(fieldOutputType)

null
}
}

Expand All @@ -229,8 +225,7 @@ internal class NadelHydrationValidation(
MissingHydrationArgumentValueSource(parent, overallField, remoteArgSource)
} else {
// TODO: check argument type is correct
val hydrationArgType = argument.type
hydrationArgTypesMatch(hydrationArgType)
null
}
}

Expand All @@ -239,9 +234,4 @@ internal class NadelHydrationValidation(
}
}
}

private fun hydrationArgTypesMatch(type: GraphQLType): NadelSchemaValidationError? { //getHydrationArgumentErrors
// if type matches, return null, otherwise return error
return null
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -59,18 +59,11 @@ class GatewaySchemaWiringFactory : NeverWiringFactory() {
.coercing(Scalars.GraphQLString.coercing)
.build()

// private val jsonScalar = GraphQLScalarType.newScalar()
// .name("JSON")
// .description("JSON Scalar type")
// .coercing(ExtendedScalars.Json.coercing)
// .build()

private val defaultScalars = mapOf(
urlScalar.name to urlScalar,
ExtendedScalars.Json.name to ExtendedScalars.Json,
ExtendedScalars.GraphQLLong.name to ExtendedScalars.GraphQLLong,
dateTimeScalar.name to dateTimeScalar,
// jsonScalar.name to jsonScalar,
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,7 @@ class `basic-hydration` : HydrationDetailsHook() {
assert(actualHydrationDetails.hydrationSourceService.name == "service1")
}
}
@UseHook
class `basic-hydration-with-static-args` : HydrationDetailsHook() {
override fun assertHydrationDetails(actualHydrationDetails: ServiceExecutionHydrationDetails) {
assert(actualHydrationDetails.hydrationActorField.toString() == "Query.barById")
assert(actualHydrationDetails.hydrationSourceField.toString() == "Foo.bar")
assert(actualHydrationDetails.hydrationSourceService.name == "service1")
}
}

@UseHook
class `batch-hydration-with-renamed-actor-field` : HydrationDetailsHook() {
override fun assertHydrationDetails(actualHydrationDetails: ServiceExecutionHydrationDetails) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: "basic hydration with static arg number"
name: "basic hydration with static arg integer"
enabled: true
overallSchema:
service2: |
Expand Down

0 comments on commit 9a58595

Please sign in to comment.