Skip to content
This repository has been archived by the owner on Oct 15, 2024. It is now read-only.

Commit

Permalink
chore(package.json): update eslint ignore pattern to include graphql/…
Browse files Browse the repository at this point in the history
…code-gen directory

fix(graphql.ts): add type annotation to Result import from rustic-error package
fix(graphql.ts): add type annotation to response.json() method return value
style(index.ts): add missing semicolons and newline at end of file
  • Loading branch information
Bluzzi committed Jun 3, 2023
1 parent b8b6364 commit e5e8fd1
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 7 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
"eslintConfig": {
"extends": "@bluzzi",
"ignorePatterns": [
"src/utils/request/graphql"
"src/utils/request/graphql/code-gen"
]
},
"engines": {
Expand Down
5 changes: 3 additions & 2 deletions src/utils/request/graphql/graphql.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import type { TypedDocumentNode } from "@graphql-typed-document-node/core";
import { print } from "graphql";
import { logger } from "#/utils/logger";
import { Result, error, ok } from "rustic-error";
import type { Result } from "rustic-error";
import { error, ok } from "rustic-error";
import { env } from "#/configs/env";

export const gqlRequest = async<D, V>(document: TypedDocumentNode<D, V>, variables?: V): Promise<Result<D, Error>> => {
Expand All @@ -24,5 +25,5 @@ export const gqlRequest = async<D, V>(document: TypedDocumentNode<D, V>, variabl
return error(Error("GraphQL request failed"));
}

return ok((await response.json()).data)
return ok((await response.json() as { data: D }).data);
};
8 changes: 4 additions & 4 deletions src/utils/request/graphql/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
export * from "./graphql"
export * from "./graphql";

// Code gen:
export * from "./code-gen/gql"
export * from "./code-gen/graphql"
export * from "./code-gen/fragment-masking"
export * from "./code-gen/gql";
export * from "./code-gen/graphql";
export * from "./code-gen/fragment-masking";

0 comments on commit e5e8fd1

Please sign in to comment.