diff --git a/README.md b/README.md
index 0af382a3a..1854e9705 100644
--- a/README.md
+++ b/README.md
@@ -25,6 +25,9 @@ Minimal GraphQL client supporting Node and browsers for scripts or simple apps.
- [Why do I have to install `graphql`?](#why-do-i-have-to-install-graphql)
- [Do I need to wrap my GraphQL documents inside the `gql` template exported by `graphql-request`?](#do-i-need-to-wrap-my-graphql-documents-inside-the-gql-template-exported-by-graphql-request)
- [What sets `graphql-request` apart from other clients like Apollo, Relay, etc.?](#what-sets-graphql-request-apart-from-other-clients-like-apollo-relay-etc)
+- [Project Stats](#project-stats)
+ - [Package Installs](#package-installs)
+ - [Repo Beats](#repo-beats)
@@ -119,12 +122,6 @@ await client.request(document)
- [Middleware](./examples/other-middleware.ts)
- [Error Handling](./examples/other-error-handling.ts)
-## Usage Trend
-
-[Usage Trend of graphql-request](https://npm-compare.com/graphql-request/#timeRange=THREE_YEARS)
-
-![image](https://github.com/jasonkuhrt/graphql-request/assets/3455798/8d27c215-f20f-46f9-b38d-61f41d14882f)
-
## Node Version Support
We only (officially) support [versions of Nodejs](https://github.com/nodejs/Release#release-schedule) of the following status:
@@ -203,3 +200,15 @@ No. It is there for convenience so that you can get the tooling support like aut
`graphql-request` is the most minimal and simplest to use GraphQL client. It's perfect for small scripts or simple apps.
Compared to GraphQL clients like Apollo or Relay, `graphql-request` doesn't have a built-in cache and has no integrations for frontend frameworks. The goal is to keep the package and API as minimal as possible.
+
+## Project Stats
+
+### Package Installs
+
+
+
+
+
+### Repo Beats
+
+![Alt](https://repobeats.axiom.co/api/embed/aeb7beaee43b190e90868357c5a2898f517fb63e.svg "Repobeats analytics image")
diff --git a/package.json b/package.json
index 60cd364f1..153824faf 100644
--- a/package.json
+++ b/package.json
@@ -80,15 +80,26 @@
"release:pr": "dripip pr"
},
"dependencies": {
- "@dprint/formatter": "^0.3.0",
- "@dprint/typescript": "^0.91.1",
"@graphql-typed-document-node/core": "^3.2.0",
"@molt/command": "^0.9.0",
- "dprint": "^0.46.2",
"zod": "^3.23.8"
},
"peerDependencies": {
- "graphql": "14 - 16"
+ "graphql": "14 - 16",
+ "dprint": "^0.46.2",
+ "@dprint/formatter": "^0.3.0",
+ "@dprint/typescript": "^0.91.1"
+ },
+ "peerDependenciesMeta": {
+ "dprint": {
+ "optional": true
+ },
+ "@dprint/formatter": {
+ "optional": true
+ },
+ "@dprint/typescript": {
+ "optional": true
+ }
},
"devDependencies": {
"@arethetypeswrong/cli": "^0.15.3",
diff --git a/src/layers/2_generator/files.ts b/src/layers/2_generator/files.ts
index c27365f6d..cf13b278c 100644
--- a/src/layers/2_generator/files.ts
+++ b/src/layers/2_generator/files.ts
@@ -1,5 +1,4 @@
-import { createFromBuffer } from '@dprint/formatter'
-import { getPath } from '@dprint/typescript'
+import type { Formatter } from '@dprint/formatter'
import _ from 'json-bigint'
import fs from 'node:fs/promises'
import * as Path from 'node:path'
@@ -18,6 +17,16 @@ export interface Input {
errorTypeNamePattern?: OptionsInput['errorTypeNamePattern']
}
+const getTypeScriptFormatter = async (): Promise => {
+ try {
+ const { createFromBuffer } = await import(`@dprint/formatter`)
+ const { getPath } = await import(`@dprint/typescript`)
+ return createFromBuffer(await fs.readFile(getPath()))
+ } catch (error) {
+ return undefined
+ }
+}
+
export const generateFiles = async (input: Input) => {
const sourceDirPath = input.sourceDirPath ?? process.cwd()
const schemaPath = input.schemaPath ?? Path.join(sourceDirPath, `schema.graphql`)
@@ -31,7 +40,7 @@ export const generateFiles = async (input: Input) => {
customScalarCodecsFilePath.replace(/\.ts$/, `.js`),
)
const customScalarCodecsPathExists = await fileExists(customScalarCodecsFilePath)
- const typeScriptFormatter = (input.format ?? true) ? createFromBuffer(await fs.readFile(getPath())) : undefined
+ const typeScriptFormatter = (input.format ?? true) ? await getTypeScriptFormatter() : undefined
const codes = generateCode({
name: input.name,