Skip to content

Commit

Permalink
refactor: use dprint instead of prettier (#677)
Browse files Browse the repository at this point in the history
  • Loading branch information
jasonkuhrt committed Feb 17, 2024
1 parent 2a121c6 commit cc86c34
Show file tree
Hide file tree
Showing 32 changed files with 322 additions and 211 deletions.
4 changes: 3 additions & 1 deletion .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,7 @@
"root": true,
"extends": ["prisma"],
"overrides": [],
"rules": {}
"rules": {
"simple-import-sort/imports": "off"
}
}
6 changes: 5 additions & 1 deletion .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
{
"recommendations": ["esbenp.prettier-vscode", "dbaeumer.vscode-eslint", "orta.vscode-twoslash-queries"]
"recommendations": [
"dprint.dprint",
"dbaeumer.vscode-eslint",
"orta.vscode-twoslash-queries"
]
}
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ npm add graphql-request graphql
Send a GraphQL document using a static request function:

```js
import { request, gql } from 'graphql-request'
import { gql, request } from 'graphql-request'

const document = gql`
{
Expand All @@ -73,7 +73,7 @@ await request({
A class is available for constructing your own instances:

```js
import { GraphQLClient, gql } from 'graphql-request'
import { gql, GraphQLClient } from 'graphql-request'

const document = gql`
{
Expand Down Expand Up @@ -185,7 +185,7 @@ In [this issue](https://github.com/jasonkuhrt/graphql-request/issues/500) we dec

#### Do I need to wrap my GraphQL documents inside the `gql` template exported by `graphql-request`?

No. It is there for convenience so that you can get the tooling support like prettier formatting and IDE syntax highlighting. You can use `gql` from `graphql-tag` if you need it for some reason too.
No. It is there for convenience so that you can get the tooling support like automatic formatting and syntax highlighting. You can use `gql` from `graphql-tag` if you need it for some reason too.

#### What sets `graphql-request` apart from other clients like Apollo, Relay, etc.?

Expand Down
19 changes: 19 additions & 0 deletions dprint.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"typescript": {
"quoteStyle": "preferSingle",
"semiColons": "asi"
},
"json": {
},
"markdown": {
},
"excludes": [
"**/node_modules",
"**/*-lock.json"
],
"plugins": [
"https://plugins.dprint.dev/typescript-0.89.1.wasm",
"https://plugins.dprint.dev/json-0.19.1.wasm",
"https://plugins.dprint.dev/markdown-0.16.3.wasm"
]
}
2 changes: 1 addition & 1 deletion examples/configuration-fetch-custom-function.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { gql, GraphQLClient } from '../src/entrypoints/main.js'
import fetchCookie from 'fetch-cookie'
import { gql, GraphQLClient } from '../src/entrypoints/main.js'

const endpoint = `https://api.graph.cool/simple/v1/cixos23120m0n0173veiiwrjr`

Expand Down
2 changes: 1 addition & 1 deletion examples/configuration-request-json-serializer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
* An original use case for this feature is `BigInt` support:
*/

import { gql, GraphQLClient } from '../src/entrypoints/main.js'
import JSONbig from 'json-bigint'
import { gql, GraphQLClient } from '../src/entrypoints/main.js'

const jsonSerializer = JSONbig({ useNativeBigInt: true })
const graphQLClient = new GraphQLClient(`https://some-api`, { jsonSerializer })
Expand Down
2 changes: 1 addition & 1 deletion examples/typescript-typed-document-node.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { gql, GraphQLClient, request } from '../src/entrypoints/main.js'
import type { TypedDocumentNode } from '@graphql-typed-document-node/core'
import { parse } from 'graphql'
import { gql, GraphQLClient, request } from '../src/entrypoints/main.js'

{
const endpoint = `https://graphql-yoga.com/api/graphql`
Expand Down
15 changes: 6 additions & 9 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,14 @@
"homepage": "https://github.com/jasonkuhrt/graphql-request",
"scripts": {
"dev": "rm -rf dist && tsc --watch",
"format": "pnpm build:docs && prettier --write .",
"format": "pnpm build:docs && dprint fmt",
"lint": "eslint . --ext .ts,.tsx --fix",
"check": "pnpm check:types && pnpm check:format && pnpm check:lint",
"check:types": "pnpm tsc --noEmit",
"check:format": "prettier --check . && pnpm build:docs && git diff --exit-code README.md",
"check:format": "dprint check && pnpm build:docs && git diff --exit-code README.md",
"check:lint": "eslint . --ext .ts,.tsx --max-warnings 0",
"prepublishOnly": "pnpm build",
"build:docs": "doctoc README.md --notitle && prettier --write README.md",
"build:docs": "doctoc README.md --notitle && dprint fmt README.md",
"build": "pnpm clean && pnpm tsc --project tsconfig.build.json",
"clean": "tsc --build --clean && rm -rf build",
"test": "vitest",
Expand All @@ -54,14 +54,14 @@
"release:pr": "dripip pr"
},
"dependencies": {
"@graphql-typed-document-node/core": "^3.2.0"
"@graphql-typed-document-node/core": "^3.2.0",
"dprint": "^0.45.0"
},
"peerDependencies": {
"graphql": "14 - 16"
},
"devDependencies": {
"@graphql-tools/schema": "^10.0.2",
"@prisma-labs/prettier-config": "^0.1.0",
"@tsconfig/node16": "^16.1.1",
"@types/body-parser": "^1.19.5",
"@types/express": "^4.17.21",
Expand All @@ -75,7 +75,6 @@
"doctoc": "^2.2.1",
"dripip": "^0.10.0",
"eslint": "^8.56.0",
"eslint-config-prettier": "^9.1.0",
"eslint-config-prisma": "^0.2.0",
"eslint-plugin-deprecation": "^2.0.0",
"eslint-plugin-only-warn": "^1.1.0",
Expand All @@ -90,12 +89,10 @@
"graphql-ws": "^5.14.3",
"happy-dom": "^13.3.1",
"json-bigint": "^1.0.0",
"prettier": "^3.2.4",
"tsx": "^4.7.0",
"type-fest": "^4.10.1",
"typescript": "^5.3.3",
"vitest": "^1.2.1",
"ws": "^8.16.0"
},
"prettier": "@prisma-labs/prettier-config"
}
}
92 changes: 73 additions & 19 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 6 additions & 4 deletions src/legacy/classes/ClientError.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,12 @@ export class ClientError extends Error {
public request: GraphQLRequestContext

constructor(response: GraphQLResponse, request: GraphQLRequestContext) {
const message = `${ClientError.extractMessage(response)}: ${JSON.stringify({
response,
request,
})}`
const message = `${ClientError.extractMessage(response)}: ${
JSON.stringify({
response,
request,
})
}`

super(message)

Expand Down

0 comments on commit cc86c34

Please sign in to comment.