Gathering detailed insights and metrics for babel-plugin-graphql-import
Gathering detailed insights and metrics for babel-plugin-graphql-import
Gathering detailed insights and metrics for babel-plugin-graphql-import
Gathering detailed insights and metrics for babel-plugin-graphql-import
babel-plugin-import-graphql
Babel plugin to make .gql/.graphql files importable
babel-plugin-inline-import
Babel plugin to make raw files importable
babel-plugin-import-graphql-files
Babel plugin to import .gql,.graphql files
babel-plugin-inline-import-graphql-ast
Babel plugin to make .gql/.graphql files importable
npm install babel-plugin-graphql-import
Typescript
Module System
Node Version
NPM Version
JavaScript (100%)
Total Downloads
0
Last Day
0
Last Week
0
Last Month
0
Last Year
0
MIT License
2 Stars
139 Commits
1 Watchers
2 Branches
1 Contributors
Updated on Jan 27, 2018
Latest Version
2.0.0
Package Id
babel-plugin-graphql-import@2.0.0
Size
4.82 kB
NPM Version
5.6.0
Node Version
9.3.0
Cumulative downloads
Total Downloads
Last Day
0%
NaN
Compared to previous day
Last Week
0%
NaN
Compared to previous week
Last Month
0%
NaN
Compared to previous month
Last Year
0%
NaN
Compared to previous year
Babel plugin to add the opportunity to use import
with raw/literal content
It is good e.g. for importing *.graphql
files into your code.
Before (without Babel-GraphQL-Import):
1// server.js 2 3// bad syntax highlighting, no syntax checking 4const typeDefinitions = ` 5type Query { 6 testString: String 7} 8schema { 9 query: Query 10} 11`; 12 13graphQLServer({ 14 schema: [typeDefinitions], 15 ... 16});
Now (with Babel-GraphQL-Import):
1// /some/schema.graphql 2type Query { 3 testString: String 4} 5schema { 6 query: Query 7}
1// server.js 2import schema from '/some/schema.graphql'; 3 4graphQLServer({ 5 schema: [schema], 6 ... 7});
Note: both cases are equivalent and will result in similar code after Babel transpile them. Check How it works section for details.
npm install babel-plugin-graphql-import --save-dev
Add a .babelrc
file and write:
1{ 2 "plugins": [ 3 "babel-plugin-graphql-import" 4 ] 5}
or pass the plugin with the plugins-flag on CLI
babel-node myfile.js --plugins babel-plugin-graphql-import
By default, Babel-GraphQL-Import is compatible with the following file extensions:
If you want to enable different file extensions, you can define them in your .babelrc
file
1{ 2 "plugins": [ 3 ["babel-plugin-graphql-import", { 4 "extensions": [ 5 ".json", 6 ".sql" 7 ] 8 }] 9 ] 10}
It inserts the content of the imported file directly into the importing file, assigning it to a variable with the same identifier of the import statement, thus replacing the import statement and the file path by its resulting raw content (no parsing occurs).
Babel does not track dependency between imported and importing files after the transformation is made. Therefore, you need to change the importing file in order to see your changes in the imported file spread. To overcome this:
babel-node
or babel-register
, you can disable babel cache (BABEL_DISABLE_CACHE=1
).babel-loader
, you can use babel-inline-import-loader.Also make sure that your task runner is watching for changes in the imported file as well. You can see it working here.
If you like this project just give it a star :) I like stars.
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
license file detected
Details
Reason
Found 0/30 approved changesets -- score normalized to 0
Reason
no SAST tool detected
Details
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
Reason
project is not fuzzed
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
75 existing vulnerabilities detected
Details
Score
Last Scanned on 2025-07-07
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More