Skip to content

Commit 366da25

Browse files
authored
fix: rename top level generated interfaces to be more explicit (#76)
1 parent 884884b commit 366da25

File tree

3 files changed

+7
-7
lines changed

3 files changed

+7
-7
lines changed

docs/docs/inheritance.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,8 +114,8 @@ Instead, you should inherit from the field-level generated `Query` classes like
114114

115115
```kotlin
116116
import com.expediagroup.graphql.server.operations.Query
117-
import com.types.generated.FooQuery as FooQueryInterface
118-
import com.types.generated.BarQuery as BarQueryInterface
117+
import com.types.generated.FooQueryInterface
118+
import com.types.generated.BarQueryInterface
119119

120120
class FooQuery : Query, FooQueryInterface() {
121121
override fun foo(): String = "Hello"

src/definitions/object.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ export function buildObjectTypeDefinition(
7777
node.name.value === "Query" || node.name.value === "Mutation";
7878
if (isTopLevelType) {
7979
const individualQueryClasses = node.fields?.map((fieldNode) => {
80-
const className = `${titleCase(fieldNode.name.value)}${node.name.value}`;
80+
const className = `${titleCase(fieldNode.name.value)}${node.name.value}Interface`;
8181
return `${annotations}${outputRestrictionAnnotation}open class ${className}${interfaceInheritance} {
8282
${getClassMembers({ node, fieldNodes: [fieldNode], schema, config })}
8383
}`;

test/unit/should_handle_top_level_types_properly/expected.kt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,12 @@ open class Query {
99
}
1010

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

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

@@ -25,11 +25,11 @@ open class Mutation {
2525
}
2626

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

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

0 commit comments

Comments
 (0)