Skip to content

Commit 862af4e

Browse files
committed
Lint fixes
1 parent 2a38e1a commit 862af4e

File tree

3 files changed

+20
-15
lines changed

3 files changed

+20
-15
lines changed

README.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ generation and other such functionality.
1818
Which command you use will depend on your setup; if you're using `graphql-toe`
1919
then you'll want `semantic-to-strict` to really capitalize on the benefits of
2020
semantic nullability. If you just want to use a semantic nullability SDL with
21-
traditional tools that don't yet understand it, then `semantic-to-nullable`
22-
will just strip out the semantic-non-null types for you.
21+
traditional tools that don't yet understand it, then `semantic-to-nullable` will
22+
just strip out the semantic-non-null types for you.
2323

2424
## Installation
2525

@@ -37,8 +37,8 @@ pnpm install --save graphql-sock
3737

3838
If a value is "null only on error" then it can be null. This conversion strips
3939
all semantic-non-null type wrappers from the SDL, making a schema that appears
40-
as it traditionally would. This means that you won't reap any of the benefits
41-
of semantic nullability, but you can support existing tools.
40+
as it traditionally would. This means that you won't reap any of the benefits of
41+
semantic nullability, but you can support existing tools.
4242

4343
```
4444
semantic-to-nullable -i input.graphql -o output.graphql
@@ -52,8 +52,8 @@ will be thrown, then it will not be possible for you to read a `null` from a
5252
"null only on error" position. As such, this position becomes equivalent to a
5353
traditional non-null for you, so this conversion converts all semantic-non-null
5454
type wrappers into traditional non-null wrappers. Your type generators can
55-
therefore generate fewer nullables, and your frontend engineers have to do
56-
fewer null checks and are therefore happier.
55+
therefore generate fewer nullables, and your frontend engineers have to do fewer
56+
null checks and are therefore happier.
5757

5858
```
5959
semantic-to-strict -i input.graphql -o output.graphql

src/cli.ts

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
import { readFile, writeFile } from "node:fs/promises";
2+
import { parseArgs } from "node:util";
3+
14
import {
25
buildSchema,
36
GraphQLFieldConfig,
@@ -17,8 +20,6 @@ import {
1720
validateSchema,
1821
} from "graphql";
1922
import type { Maybe } from "graphql/jsutils/Maybe";
20-
import { readFile, writeFile } from "node:fs/promises";
21-
import { parseArgs } from "node:util";
2223

2324
export async function main(toStrict = false) {
2425
const {
@@ -83,7 +84,7 @@ export function semanticToStrict(schema: GraphQLSchema) {
8384
function makeConvertType(toStrict: boolean) {
8485
const cache = new Map<string, GraphQLNamedType>();
8586

86-
function convertFields(fields: GraphQLFieldConfigMap<any, any>) {
87+
function convertFields(fields: GraphQLFieldConfigMap<unknown, unknown>) {
8788
return () => {
8889
return Object.fromEntries(
8990
Object.entries(fields).map(([fieldName, inSpec]) => {
@@ -96,7 +97,7 @@ function makeConvertType(toStrict: boolean) {
9697
},
9798
];
9899
}),
99-
) as any;
100+
) as GraphQLFieldConfigMap<unknown, unknown>;
100101
};
101102
}
102103

@@ -115,7 +116,9 @@ function makeConvertType(toStrict: boolean) {
115116
function convertTypes(
116117
types: readonly GraphQLNamedType[] | null | undefined,
117118
): undefined | (() => readonly GraphQLNamedType[]) {
118-
if (!types) return undefined;
119+
if (!types) {
120+
return undefined;
121+
}
119122
return () => types.map((t) => convertType(t));
120123
}
121124

@@ -127,7 +130,9 @@ function makeConvertType(toStrict: boolean) {
127130
function convertType(type: GraphQLNamedType): GraphQLNamedType;
128131
function convertType(type: GraphQLType): GraphQLType;
129132
function convertType(type: GraphQLType | null | undefined) {
130-
if (!type) return type;
133+
if (!type) {
134+
return type;
135+
}
131136
if (type instanceof GraphQLSemanticNonNull) {
132137
const unwrapped = convertType(type.ofType);
133138
// Here's where we do our thing!
@@ -187,8 +192,8 @@ function makeConvertType(toStrict: boolean) {
187192
* @see {@url https://www.apollographql.com/docs/kotlin/advanced/nullability/#semanticnonnull}
188193
*/
189194
export function applySemanticNonNullDirectiveToFieldConfig(
190-
spec: GraphQLFieldConfig<any, any, any>,
191-
): GraphQLFieldConfig<any, any, any> {
195+
spec: GraphQLFieldConfig<unknown, unknown, unknown>,
196+
): GraphQLFieldConfig<unknown, unknown, unknown> {
192197
const directive = spec.astNode?.directives?.find(
193198
(d) => d.name.value === "semanticNonNull",
194199
);

src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
export {
2+
applySemanticNonNullDirectiveToFieldConfig,
23
semanticToNullable,
34
semanticToStrict,
4-
applySemanticNonNullDirectiveToFieldConfig,
55
} from "./cli.js";

0 commit comments

Comments
 (0)