File tree Expand file tree Collapse file tree 12 files changed +22
-21
lines changed
test/unit/should_handle_query_type_properly Expand file tree Collapse file tree 12 files changed +22
-21
lines changed Original file line number Diff line number Diff line change 22
22
"@graphql-codegen/java-common" : " 3.0.0" ,
23
23
"@graphql-codegen/plugin-helpers" : " 5.0.4" ,
24
24
"@graphql-codegen/visitor-plugin-common" : " 5.2.0" ,
25
+ "ts-deepmerge" : " 7.0.0" ,
25
26
"valibot" : " 0.30.0"
26
27
},
27
28
"devDependencies" : {
Original file line number Diff line number Diff line change @@ -14,14 +14,14 @@ limitations under the License.
14
14
import { EnumTypeDefinitionNode , EnumValueDefinitionNode } from "graphql" ;
15
15
import { indentMultiline } from "@graphql-codegen/visitor-plugin-common" ;
16
16
import { buildAnnotations } from "../helpers/build-annotations" ;
17
- import { shouldIncludeTypeDefinition } from "../helpers/should-include -type-definition" ;
17
+ import { shouldExcludeTypeDefinition } from "../helpers/should-exclude -type-definition" ;
18
18
import { CodegenConfigWithDefaults } from "../helpers/build-config-with-defaults" ;
19
19
20
20
export function buildEnumTypeDefinition (
21
21
node : EnumTypeDefinitionNode ,
22
22
config : CodegenConfigWithDefaults ,
23
23
) {
24
- if ( ! shouldIncludeTypeDefinition ( node , config ) ) {
24
+ if ( shouldExcludeTypeDefinition ( node , config ) ) {
25
25
return "" ;
26
26
}
27
27
Original file line number Diff line number Diff line change @@ -12,7 +12,7 @@ limitations under the License.
12
12
*/
13
13
14
14
import { GraphQLSchema , InputObjectTypeDefinitionNode } from "graphql" ;
15
- import { shouldIncludeTypeDefinition } from "../helpers/should-include -type-definition" ;
15
+ import { shouldExcludeTypeDefinition } from "../helpers/should-exclude -type-definition" ;
16
16
import { buildTypeMetadata } from "../helpers/build-type-metadata" ;
17
17
import { buildAnnotations } from "../helpers/build-annotations" ;
18
18
import { indent } from "@graphql-codegen/visitor-plugin-common" ;
@@ -24,7 +24,7 @@ export function buildInputObjectDefinition(
24
24
schema : GraphQLSchema ,
25
25
config : CodegenConfigWithDefaults ,
26
26
) {
27
- if ( ! shouldIncludeTypeDefinition ( node , config ) ) {
27
+ if ( shouldExcludeTypeDefinition ( node , config ) ) {
28
28
return "" ;
29
29
}
30
30
Original file line number Diff line number Diff line change @@ -14,7 +14,7 @@ limitations under the License.
14
14
import { GraphQLSchema , InterfaceTypeDefinitionNode } from "graphql" ;
15
15
import { buildAnnotations } from "../helpers/build-annotations" ;
16
16
import { buildTypeMetadata } from "../helpers/build-type-metadata" ;
17
- import { shouldIncludeTypeDefinition } from "../helpers/should-include -type-definition" ;
17
+ import { shouldExcludeTypeDefinition } from "../helpers/should-exclude -type-definition" ;
18
18
import { buildFieldDefinition } from "../helpers/build-field-definition" ;
19
19
import { CodegenConfigWithDefaults } from "../helpers/build-config-with-defaults" ;
20
20
import { getDependentInterfaceNames } from "../helpers/dependent-type-utils" ;
@@ -24,7 +24,7 @@ export function buildInterfaceDefinition(
24
24
schema : GraphQLSchema ,
25
25
config : CodegenConfigWithDefaults ,
26
26
) {
27
- if ( ! shouldIncludeTypeDefinition ( node , config ) ) {
27
+ if ( shouldExcludeTypeDefinition ( node , config ) ) {
28
28
return "" ;
29
29
}
30
30
Original file line number Diff line number Diff line change @@ -19,7 +19,7 @@ import {
19
19
} from "graphql" ;
20
20
import { buildAnnotations } from "../helpers/build-annotations" ;
21
21
import { buildTypeMetadata } from "../helpers/build-type-metadata" ;
22
- import { shouldIncludeTypeDefinition } from "../helpers/should-include -type-definition" ;
22
+ import { shouldExcludeTypeDefinition } from "../helpers/should-exclude -type-definition" ;
23
23
import {
24
24
getDependentInterfaceNames ,
25
25
getDependentUnionsForType ,
@@ -34,7 +34,7 @@ export function buildObjectTypeDefinition(
34
34
schema : GraphQLSchema ,
35
35
config : CodegenConfigWithDefaults ,
36
36
) {
37
- if ( ! shouldIncludeTypeDefinition ( node , config ) ) {
37
+ if ( shouldExcludeTypeDefinition ( node , config ) ) {
38
38
return "" ;
39
39
}
40
40
Original file line number Diff line number Diff line change @@ -12,7 +12,7 @@ limitations under the License.
12
12
*/
13
13
14
14
import { UnionTypeDefinitionNode } from "graphql" ;
15
- import { shouldIncludeTypeDefinition } from "../helpers/should-include -type-definition" ;
15
+ import { shouldExcludeTypeDefinition } from "../helpers/should-exclude -type-definition" ;
16
16
import { CodegenConfigWithDefaults } from "../helpers/build-config-with-defaults" ;
17
17
import {
18
18
buildAnnotations ,
@@ -23,7 +23,7 @@ export function buildUnionTypeDefinition(
23
23
node : UnionTypeDefinitionNode ,
24
24
config : CodegenConfigWithDefaults ,
25
25
) {
26
- if ( ! shouldIncludeTypeDefinition ( node , config ) ) {
26
+ if ( shouldExcludeTypeDefinition ( node , config ) ) {
27
27
return "" ;
28
28
}
29
29
const annotations = buildAnnotations ( {
Original file line number Diff line number Diff line change 1
1
import { GraphQLKotlinCodegenConfig } from "../plugin" ;
2
2
import { buildPackageNameFromPath } from "@graphql-codegen/java-common" ;
3
3
import { dirname , normalize } from "path" ;
4
+ import { merge } from "ts-deepmerge" ;
4
5
5
6
export function buildConfigWithDefaults (
6
7
config : GraphQLKotlinCodegenConfig ,
7
8
outputFile : string ,
8
9
) {
9
- return {
10
+ const defaultConfig = {
10
11
packageName : buildPackageNameFromPath ( dirname ( normalize ( outputFile ) ) ) ,
11
12
includeDependentTypes : true ,
12
13
unionGeneration : "MARKER_INTERFACE" ,
13
- ...config ,
14
- extraImports : [
15
- "com.expediagroup.graphql.generator.annotations.*" ,
16
- ...( config . extraImports ?? [ ] ) ,
17
- ] ,
14
+ extraImports : [ "com.expediagroup.graphql.generator.annotations.*" ] ,
15
+ resolverInterfaces : [ { typeName : "Query" } ] ,
18
16
} as const satisfies GraphQLKotlinCodegenConfig ;
17
+
18
+ return merge ( defaultConfig , config ) as GraphQLKotlinCodegenConfig &
19
+ typeof defaultConfig ;
19
20
}
20
21
21
22
export type CodegenConfigWithDefaults = ReturnType <
Original file line number Diff line number Diff line change @@ -5,7 +5,7 @@ export function findTypeInResolverInterfacesConfig(
5
5
node : ObjectTypeDefinitionNode | InterfaceTypeDefinitionNode ,
6
6
config : CodegenConfigWithDefaults ,
7
7
) {
8
- return config . resolverInterfaces ? .find (
8
+ return config . resolverInterfaces . find (
9
9
( resolverInterface ) => resolverInterface . typeName === node . name . value ,
10
10
) ;
11
11
}
Original file line number Diff line number Diff line change @@ -14,9 +14,9 @@ limitations under the License.
14
14
import { TypeDefinitionNode } from "graphql" ;
15
15
import { CodegenConfigWithDefaults } from "./build-config-with-defaults" ;
16
16
17
- export function shouldIncludeTypeDefinition (
17
+ export function shouldExcludeTypeDefinition (
18
18
node : TypeDefinitionNode ,
19
19
config : CodegenConfigWithDefaults ,
20
20
) {
21
- return ! config . onlyTypes || config . onlyTypes . includes ( node . name . value ) ;
21
+ return config . onlyTypes && ! config . onlyTypes . includes ( node . name . value ) ;
22
22
}
You can’t perform that action at this time.
0 commit comments