-
Notifications
You must be signed in to change notification settings - Fork 354
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: move default implementations to interface (#68)
* feat: move default implementations to interface * fix: update unit tests
- Loading branch information
1 parent
f8b68d8
commit 11f2e9a
Showing
10 changed files
with
53 additions
and
79 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
43 changes: 3 additions & 40 deletions
43
src/main/kotlin/com/expedia/graphql/schema/hooks/NoopSchemaGeneratorHooks.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,44 +1,7 @@ | ||
package com.expedia.graphql.schema.hooks | ||
|
||
import graphql.schema.DataFetcher | ||
import graphql.schema.GraphQLFieldDefinition | ||
import graphql.schema.GraphQLSchema | ||
import graphql.schema.GraphQLType | ||
import java.util.concurrent.CompletableFuture | ||
import kotlin.reflect.KFunction | ||
import kotlin.reflect.KProperty | ||
import kotlin.reflect.KType | ||
|
||
/** | ||
* Default hooks that do not override or set anything. | ||
* | ||
* To set your own custom hooks, it is easier to extend this class instead of SchemaGeneratorHooks | ||
* and just override the methods you need. | ||
* Default hooks that do not override or set anything. Only used internally. | ||
* If you don't need hooks, the configuration will default to these. | ||
*/ | ||
open class NoopSchemaGeneratorHooks : SchemaGeneratorHooks { | ||
|
||
override fun willBuildSchema(builder: GraphQLSchema.Builder): GraphQLSchema.Builder = builder | ||
|
||
override fun willGenerateGraphQLType(type: KType): GraphQLType? = null | ||
|
||
override fun willResolveMonad(type: KType): KType = | ||
if (type.classifier == CompletableFuture::class) { | ||
type.arguments.firstOrNull()?.type ?: type | ||
} else { | ||
type | ||
} | ||
|
||
override fun isValidProperty(property: KProperty<*>) = true | ||
|
||
override fun isValidFunction(function: KFunction<*>) = true | ||
|
||
override fun didGenerateGraphQLType(type: KType, generatedType: GraphQLType) = Unit | ||
|
||
override fun didGenerateDataFetcher(function: KFunction<*>, dataFetcher: DataFetcher<*>) = dataFetcher | ||
|
||
override fun didGenerateQueryType(function: KFunction<*>, fieldDefinition: GraphQLFieldDefinition) = fieldDefinition | ||
|
||
override fun didGenerateMutationType(function: KFunction<*>, fieldDefinition: GraphQLFieldDefinition) = fieldDefinition | ||
|
||
override val dataFetcherExecutionPredicate: DataFetcherExecutionPredicate? = null | ||
} | ||
internal class NoopSchemaGeneratorHooks : SchemaGeneratorHooks |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters