Skip to content

Commit 4832698

Browse files
authored
refactor: rename util function to the opposite for clarity (#132)
1 parent bbe0c09 commit 4832698

File tree

6 files changed

+13
-14
lines changed

6 files changed

+13
-14
lines changed

src/config/should-exclude-type-definition.ts renamed to src/config/should-include-type-definition.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,11 @@ See the License for the specific language governing permissions and
1111
limitations under the License.
1212
*/
1313

14-
import { TypeDefinitionNode } from "graphql";
1514
import { CodegenConfigWithDefaults } from "./build-config-with-defaults";
1615

17-
export function shouldExcludeTypeDefinition(
18-
node: TypeDefinitionNode,
16+
export function shouldIncludeTypeDefinition(
17+
typeName: string,
1918
config: CodegenConfigWithDefaults,
2019
) {
21-
return config.onlyTypes && !config.onlyTypes.includes(node.name.value);
20+
return !config.onlyTypes || config.onlyTypes.includes(typeName);
2221
}

src/definitions/enum.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ limitations under the License.
1414
import { EnumTypeDefinitionNode, EnumValueDefinitionNode } from "graphql";
1515
import { indentMultiline } from "@graphql-codegen/visitor-plugin-common";
1616
import { buildAnnotations } from "../annotations/build-annotations";
17-
import { shouldExcludeTypeDefinition } from "../config/should-exclude-type-definition";
17+
import { shouldIncludeTypeDefinition } from "../config/should-include-type-definition";
1818
import { CodegenConfigWithDefaults } from "../config/build-config-with-defaults";
1919
import { sanitizeName } from "../utils/sanitize-name";
2020
import { GraphQLSchema } from "graphql";
@@ -24,7 +24,7 @@ export function buildEnumTypeDefinition(
2424
schema: GraphQLSchema,
2525
config: CodegenConfigWithDefaults,
2626
) {
27-
if (shouldExcludeTypeDefinition(node, config)) {
27+
if (!shouldIncludeTypeDefinition(node.name.value, config)) {
2828
return "";
2929
}
3030

src/definitions/input.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ limitations under the License.
1212
*/
1313

1414
import { GraphQLSchema, InputObjectTypeDefinitionNode } from "graphql";
15-
import { shouldExcludeTypeDefinition } from "../config/should-exclude-type-definition";
15+
import { shouldIncludeTypeDefinition } from "../config/should-include-type-definition";
1616
import { buildTypeMetadata } from "../utils/build-type-metadata";
1717
import { buildAnnotations } from "../annotations/build-annotations";
1818
import { indent } from "@graphql-codegen/visitor-plugin-common";
@@ -25,7 +25,7 @@ export function buildInputObjectDefinition(
2525
schema: GraphQLSchema,
2626
config: CodegenConfigWithDefaults,
2727
) {
28-
if (shouldExcludeTypeDefinition(node, config)) {
28+
if (!shouldIncludeTypeDefinition(node.name.value, config)) {
2929
return "";
3030
}
3131

src/definitions/interface.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ limitations under the License.
1313

1414
import { GraphQLSchema, InterfaceTypeDefinitionNode } from "graphql";
1515
import { buildAnnotations } from "../annotations/build-annotations";
16-
import { shouldExcludeTypeDefinition } from "../config/should-exclude-type-definition";
16+
import { shouldIncludeTypeDefinition } from "../config/should-include-type-definition";
1717
import { buildInterfaceFieldDefinition } from "./field";
1818
import { CodegenConfigWithDefaults } from "../config/build-config-with-defaults";
1919
import { getDependentInterfaceNames } from "../utils/dependent-type-utils";
@@ -24,7 +24,7 @@ export function buildInterfaceDefinition(
2424
schema: GraphQLSchema,
2525
config: CodegenConfigWithDefaults,
2626
) {
27-
if (shouldExcludeTypeDefinition(node, config)) {
27+
if (!shouldIncludeTypeDefinition(node.name.value, config)) {
2828
return "";
2929
}
3030

src/definitions/object.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import {
1818
ObjectTypeDefinitionNode,
1919
} from "graphql";
2020
import { buildAnnotations } from "../annotations/build-annotations";
21-
import { shouldExcludeTypeDefinition } from "../config/should-exclude-type-definition";
21+
import { shouldIncludeTypeDefinition } from "../config/should-include-type-definition";
2222
import {
2323
getDependentInterfaceNames,
2424
getDependentUnionsForType,
@@ -37,7 +37,7 @@ export function buildObjectTypeDefinition(
3737
schema: GraphQLSchema,
3838
config: CodegenConfigWithDefaults,
3939
) {
40-
if (shouldExcludeTypeDefinition(node, config)) {
40+
if (!shouldIncludeTypeDefinition(node.name.value, config)) {
4141
return "";
4242
}
4343

src/definitions/union.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ limitations under the License.
1212
*/
1313

1414
import { GraphQLSchema, UnionTypeDefinitionNode } from "graphql";
15-
import { shouldExcludeTypeDefinition } from "../config/should-exclude-type-definition";
15+
import { shouldIncludeTypeDefinition } from "../config/should-include-type-definition";
1616
import { CodegenConfigWithDefaults } from "../config/build-config-with-defaults";
1717
import {
1818
buildAnnotations,
@@ -25,7 +25,7 @@ export function buildUnionTypeDefinition(
2525
schema: GraphQLSchema,
2626
config: CodegenConfigWithDefaults,
2727
) {
28-
if (shouldExcludeTypeDefinition(node, config)) {
28+
if (!shouldIncludeTypeDefinition(node.name.value, config)) {
2929
return "";
3030
}
3131
const annotations = buildAnnotations({

0 commit comments

Comments
 (0)