-
Notifications
You must be signed in to change notification settings - Fork 23
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
Never wiring factory tweaks #642
Changes from all commits
49bdf95
1e9b62b
4f18c38
afd39bb
58eaf42
f1b136d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,6 +7,8 @@ import graphql.language.Value | |
import graphql.scalars.ExtendedScalars | ||
import graphql.schema.Coercing | ||
import graphql.schema.DataFetcher | ||
import graphql.schema.DataFetcherFactory | ||
import graphql.schema.GraphQLCodeRegistry | ||
import graphql.schema.GraphQLScalarType | ||
import graphql.schema.TypeResolver | ||
import graphql.schema.idl.FieldWiringEnvironment | ||
|
@@ -79,39 +81,50 @@ open class NeverWiringFactory : WiringFactory { | |
} | ||
} | ||
|
||
override fun providesTypeResolver(environment: InterfaceWiringEnvironment): Boolean { | ||
final override fun providesTypeResolver(environment: InterfaceWiringEnvironment): Boolean { | ||
return true | ||
} | ||
|
||
override fun getTypeResolver(environment: InterfaceWiringEnvironment): TypeResolver { | ||
return TypeResolver { | ||
assertShouldNeverHappen("This interface type resolver should NEVER be called from Nadel") | ||
} | ||
final override fun getTypeResolver(environment: InterfaceWiringEnvironment): TypeResolver { | ||
return NEVER_TR | ||
} | ||
|
||
override fun providesTypeResolver(environment: UnionWiringEnvironment): Boolean { | ||
final override fun providesTypeResolver(environment: UnionWiringEnvironment): Boolean { | ||
return true | ||
} | ||
|
||
override fun getTypeResolver(environment: UnionWiringEnvironment): TypeResolver { | ||
final override fun getTypeResolver(environment: UnionWiringEnvironment): TypeResolver { | ||
return TypeResolver { | ||
assertShouldNeverHappen("This union type resolver should NEVER be called from Nadel") | ||
} | ||
} | ||
|
||
override fun providesDataFetcher(environment: FieldWiringEnvironment): Boolean { | ||
return true | ||
final override fun providesDataFetcher(environment: FieldWiringEnvironment): Boolean { | ||
return false | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. So we dont create a DF per field or make a CodeRegistry entry per field as well but rather use a default |
||
} | ||
|
||
override fun getDataFetcher(environment: FieldWiringEnvironment): DataFetcher<*> { | ||
return DataFetcher { | ||
assertShouldNeverHappen<Any?>("This data fetcher should NEVER be called from Nadel") | ||
} | ||
final override fun getDataFetcher(environment: FieldWiringEnvironment): DataFetcher<*> { | ||
return assertShouldNeverHappen("getDataFetcher should NEVER be called from Nadel - we returned false") | ||
} | ||
|
||
final override fun getDefaultDataFetcher(environment: FieldWiringEnvironment): DataFetcher<*>? { | ||
return null | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. no default makes it use CodeRegistry default |
||
} | ||
|
||
override fun getDefaultDataFetcher(environment: FieldWiringEnvironment): DataFetcher<*> { | ||
return DataFetcher { | ||
|
||
companion object { | ||
val NEVER_TR = TypeResolver { | ||
assertShouldNeverHappen("This interface type resolver should NEVER be called from Nadel") | ||
} | ||
private val NEVER_DF = DataFetcher { | ||
assertShouldNeverHappen<Any?>("This data fetcher should NEVER be called from Nadel") | ||
} | ||
private val NEVER_DFF = DataFetcherFactory { | ||
NEVER_DF | ||
} | ||
|
||
val NEVER_CODE_REGISTRY: GraphQLCodeRegistry = GraphQLCodeRegistry.newCodeRegistry() | ||
.defaultDataFetcher(NEVER_DFF).build() | ||
|
||
} | ||
} |
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we apply the same thing to There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. done |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bugged me