Skip to content

Commit

Permalink
fix: rename top level generated interfaces to be more explicit (#76)
Browse files Browse the repository at this point in the history
  • Loading branch information
danadajian authored May 28, 2024
1 parent 884884b commit 366da25
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
4 changes: 2 additions & 2 deletions docs/docs/inheritance.md
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,8 @@ Instead, you should inherit from the field-level generated `Query` classes like

```kotlin
import com.expediagroup.graphql.server.operations.Query
import com.types.generated.FooQuery as FooQueryInterface
import com.types.generated.BarQuery as BarQueryInterface
import com.types.generated.FooQueryInterface
import com.types.generated.BarQueryInterface

class FooQuery : Query, FooQueryInterface() {
override fun foo(): String = "Hello"
Expand Down
2 changes: 1 addition & 1 deletion src/definitions/object.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ export function buildObjectTypeDefinition(
node.name.value === "Query" || node.name.value === "Mutation";
if (isTopLevelType) {
const individualQueryClasses = node.fields?.map((fieldNode) => {
const className = `${titleCase(fieldNode.name.value)}${node.name.value}`;
const className = `${titleCase(fieldNode.name.value)}${node.name.value}Interface`;
return `${annotations}${outputRestrictionAnnotation}open class ${className}${interfaceInheritance} {
${getClassMembers({ node, fieldNodes: [fieldNode], schema, config })}
}`;
Expand Down
8 changes: 4 additions & 4 deletions test/unit/should_handle_top_level_types_properly/expected.kt
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@ open class Query {
}

@GraphQLValidObjectLocations(locations = [GraphQLValidObjectLocations.Locations.OBJECT])
open class GetStuffQuery {
open class GetStuffQueryInterface {
open fun getStuff(dataFetchingEnvironment: graphql.schema.DataFetchingEnvironment): String = throw NotImplementedError("Query.getStuff must be implemented.")
}

@GraphQLValidObjectLocations(locations = [GraphQLValidObjectLocations.Locations.OBJECT])
open class GetStuffWithInputQuery {
open class GetStuffWithInputQueryInterface {
open fun getStuffWithInput(input: String, dataFetchingEnvironment: graphql.schema.DataFetchingEnvironment): String = throw NotImplementedError("Query.getStuffWithInput must be implemented.")
}

Expand All @@ -25,11 +25,11 @@ open class Mutation {
}

@GraphQLValidObjectLocations(locations = [GraphQLValidObjectLocations.Locations.OBJECT])
open class MutateStuffMutation {
open class MutateStuffMutationInterface {
open suspend fun mutateStuff(dataFetchingEnvironment: graphql.schema.DataFetchingEnvironment): String = throw NotImplementedError("Mutation.mutateStuff must be implemented.")
}

@GraphQLValidObjectLocations(locations = [GraphQLValidObjectLocations.Locations.OBJECT])
open class MutateStuffWithInputMutation {
open class MutateStuffWithInputMutationInterface {
open suspend fun mutateStuffWithInput(input: String, dataFetchingEnvironment: graphql.schema.DataFetchingEnvironment): String = throw NotImplementedError("Mutation.mutateStuffWithInput must be implemented.")
}

0 comments on commit 366da25

Please sign in to comment.