Skip to content
PluginStats

vite-plugin-graphql-loader weekly downloads statistics

By 0x31 · npm · Vite plugins

A Vite plugin for loading GraphQL files.

View on npm Fresh · Oct 17, 2026

vite-plugin-graphql-loader has 34,361 recorded weekly downloads on npm, a decrease of 63.1% over the past 30 days.

It ranks #636 of 2,256 tracked npm listings by weekly downloads.

Over 90 days, weekly downloads changed by -76.4%.

PluginStats has 121 daily observations since Jun 19, 2026; the latest is from Oct 17, 2026.

Weekly downloads
34,361
Official API · Oct 17, 2026
7-day growth
-53.7%
-39.8K weekly downloads
30-day growth
-63.1%
-58.9K weekly downloads
90-day growth
-76.4%
-111.5K weekly downloads
Rank
#636
Among tracked npm listings

About vite-plugin-graphql-loader

vite-plugin-graphql-loader

A Vite plugin for loading GraphQL .gql and .graphql files, based on graphql-tag/loader

Using Bun as well? bun-graphql-loader is the same loader behind Bun's plugin API, built from the same source in this repository.

This package _doesn't_ generate TypeScript definitions from the queries and fragments - see vite-plugin-graphql-codegen if you require this.

Install

or

Compatibility

| Peer | Supported |

| graphql | 16.x, 17.x | | vite | 5.x, 6.x, 7.x, 8.x | | Node | ^20.19.0 \|\| >=22.12.0 (GraphQL 17 itself requires Node 22+) |

Usage

In vite.config.ts or vite.config.js:

Now you can import queries from .gql or .graphql files.

example.graphql:

example.js:

If you have multiple queries in the same file, import them like this:

TypeScript

If you are using TypeScript, you will have to declare .gql or .graphql files.

Create graphql.d.ts anywhere in your source directory:

_Alternatively_, for full type information (replacing .gql with .graphql depending on what you use):

Every export is a DocumentNode. A fragment export is a document holding that fragment and the fragments it spreads, which is what gql interpolation and fragment composition expect.

An operation whose name is a JavaScript reserved word has to be renamed on import:

Changelog

_v6.0.0_:

• Breaking: conflicting fragments in files joined by #import now fail to load instead of silently keeping the first definition. Rename conflicting fragments or use one shared definition before upgrading. • Support GraphQL 17 (fixes #13). The graphql peer range is now ^16.0.0 || ^17.0.0. CI runs the full suite against both majors. Node 20 is tested against GraphQL 16 only, since GraphQL 17 requires Node 22+. • Fix: named exports no longer carry the whole file's loc (fixes #14). Each export held only its own operation but inherited the document's loc, whose source.body is the entire file. Clients that send loc.source.body instead of printing, such as urql's stringifyDocument, therefore sent every operation in the file, so a single invalid operation broke every import from it. Every export now has a loc whose body is assembled from exactly its own definitions. The default export keeps the file's text unless definitions were merged in through #import or dropped as duplicates, in which case its body is rebuilt the same way: it used to spread fragments its own text never defined. loc is kept rather than dropped because graphql-tag's gql reads loc.source.body of every interpolated document, so gql\... ${UserFields}\`` keeps working. • Fix: ?raw, ?url, ?worker and ?sharedworker imports of .graphql files are left to Vite. The loader used to parse the JavaScript Vite had already produced for them as GraphQL and fail the build. • Fix: operations and fragments named with a JavaScript reserved word (delete, new, class...), a global the emitted module uses (Set, Object) or one of its own identifiers now load. Exports are aliased from $-prefixed locals, so only default, _queries and _fragments remain reserved. • Fix: #import lines are read past whitespace-only lines, when indented, and after a UTF-8 byte order mark. Each used to silently drop every import after it. A comment that merely starts with # import is no longer turned into a bogus ESM import, and an #import line that cannot be parsed fails the build instead of being ignored. • Fix: across #imported files, a spread always resolves to a fragment, so an operation sharing a name with an imported fragment no longer loses it. Identical definitions reached through two paths are kept once. Input type names of variables are no longer mistaken for fragment references. • Fix: a file holding one fragment and an anonymous operation exports the fragment on its own rather than as the whole document. • Fix: CRLF line endings are preserved in loc.source.body, so loc offsets match it on Windows checkouts. • Fix: emitted loc.start/loc.end now match loc.source.body. Two bugs combined to make every offset wrong: the document was parsed through a tagged template literal, so this file's own indentation was counted into the document, and graphql-tag caches parsed documents keyed by whitespace-normalized source, so two .graphql files differing only in whitespace shared one DocumentNode and inherited each other's offsets. • Fix: anonymous operations now follow GraphQL's LoneAnonymousOperation rule. A file with an anonymous operation alongside any other operation fails the build instead of silently dropping it, and a file with an anonymous operation alongside two or more fragments is no longer rejected. Fragments were previously counted as operations when deciding whether a name was required. • Identical fragments within a file are deduplicated, preserving the previous graphql-tag behaviour. Formatting and comments do not affect equality. Conflicting fragments, duplicate operations, and operations sharing a fragment name fail the build with a clear error. • _fragments is documented as Record. Its values were always documents holding the fragment, never FragmentDefinitionNodes. • Breaking (internal): graphql-tag is no longer a dependency. The loader parses with parse from the graphql peer, which has no document cache. Nested locs are still stripped to keep the emitted document small, and each top-level definition keeps its {start, end}. • magic-string is updated to 1.x. sourceMapOptions passes straight through to it, so hires now also accepts "boundary" and "experimental-range" alongside true / false. • The Vite and Bun loaders now share one implementation in this repository. bun-graphql-loader had drifted a long way behind and was missing the ${/backslash escaping, #import path validation, prototype-safe fragment dedup and reserved-name fixes. • Emitted modules now name their injected helpers graphqlLoaderUniqueChecker, graphqlLoaderExtractQuery and graphqlLoaderSourceLoc rather than vitePluginGraphqlLoader*, since the same code is emitted by both loaders. These identifiers are internal…

Description from the npm listing.

  • graphql
  • vite
  • vite-plugin

Where vite-plugin-graphql-loader sits in the listing

Each band is one page of 20. Weekly downloads on a log scale. Placement is projected from weekly downloads, so it can differ from the marketplace's own sort order. Hover a dot to see the listing.

All npm2,256 listings · 113 pages · page 32, #16 (overall #636)
All npm: every listing in weekly downloads order
PNG SVG
Vite plugins250 listings · 13 pages · page 6, #2 (overall #102)
Vite plugins: every listing in weekly downloads order
PNG SVG

Charts

Images: 30d · 1y · all time · 1600×900 dark

Adoption over time

vite-plugin-graphql-loader weekly downloads on npm, last 90 days: 34,361 weekly downloads as of Oct 17, 2026, -76.4% over 90 days.vite-plugin-graphql-loaderWeekly downloads on npm · Last 90 days34,361downloads / week-76.4% over 90 days020K40K60K80K100K120K140K160KJul 19Aug 3Aug 18Sep 2Sep 17Oct 2Oct 17downloads / weekobservedarchived (Internet Archive)no observationsJul 21, 2026 – Oct 17, 2026 · 89 observations · Updated Oc…pluginstats.com
vite-plugin-graphql-loader weekly downloads on npm, last 90 days: 34,361 weekly downloads as of Oct 17, 2026, -76.4% over 90 days.
PNG SVG

7/30/90-day growth

vite-plugin-graphql-loader weekly downloads growth on npm: -53.7% over 7 days, -63.1% over 30 days, -76.4% over 90 days.vite-plugin-graphql-loaderWeekly downloads growth on npm34,361downloads / week now7-day growth-39,828 weekly downloads-53.7%30-day growth-58,856 weekly downloads-63.1%90-day growth-111,545 weekly downloads-76.4%Growth vs. nearest observation to each baseline date · Updated Oct 17, 2026pluginstats.com
vite-plugin-graphql-loader weekly downloads growth on npm: -53.7% over 7 days, -63.1% over 30 days, -76.4% over 90 days.
PNG SVG

Ranking history

vite-plugin-graphql-loader npm ranking history: currently #636 (by weekly downloads).vite-plugin-graphql-loadernpm ranking · by weekly downloads · Last 90 days#636current rank#634#635#636#637#638Jul 21Aug 5Aug 20Sep 4Sep 19Oct 4Oct 19rankOct 18, 2026 – Oct 19, 2026 · 2 observations · Updated Oct 17, 2026pluginstats.com
vite-plugin-graphql-loader npm ranking history: currently #636 (by weekly downloads).
PNG SVG

Filled points are observed values; hollow points come from Internet Archive snapshots of the listing page. Dashed segments span periods with no observations — values between points are not interpolated.

Recent observations

Full history (121)
Recent weekly downloads observations for vite-plugin-graphql-loader
Date (UTC)Weekly downloadsChange vs. previous
34,361-3.5K
37,897-4.5K
42,392-24.7K
67,128-22.4K
89,5140
89,514+14.2K
75,265+1.1K
74,189+100
74,089+4.1K
69,997+3.5K
66,543+553
65,990-21K
87,035-20.6K
107,627—

Similar npm Vite plugins plugins

Data source

Weekly downloads (trailing 7 complete days) come from the official npm downloads API. Downloads include CI and mirrors and are not equivalent to installs or users. npm publishes no ratings.

Listing: https://www.npmjs.com/package/vite-plugin-graphql-loader. First seen Oct 16, 2026; last successful collection Oct 19, 2026. See the methodology.