Skip to content

Commit

Permalink
feat: load graphql files with graphql-tag/loader
Browse files Browse the repository at this point in the history
  • Loading branch information
dstaley committed Jan 18, 2023
1 parent 949a1fa commit 9a33aa9
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 9 deletions.
5 changes: 5 additions & 0 deletions .changeset/little-rules-invent.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@hashicorp/platform-nextjs-plugin': minor
---

Use graphql-tag/loader to support #import statements in graphql files
26 changes: 25 additions & 1 deletion package-lock.json

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

1 change: 1 addition & 0 deletions packages/nextjs-plugin/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
"dependencies": {
"@hashicorp/next-optimized-images": "0.2.0",
"@next/bundle-analyzer": "10.0.3",
"graphql-tag": "^2.12.6",
"imagemin-mozjpeg": "9.0.0",
"imagemin-optipng": "8.0.0",
"imagemin-svgo": "8.0.0",
Expand Down
4 changes: 2 additions & 2 deletions packages/nextjs-plugin/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import withBundleAnalyzer from '@next/bundle-analyzer'
import withOptimizedImages from '@hashicorp/next-optimized-images'
import withTMBase from 'next-transpile-modules'
import { NextConfig } from 'next'
import withGraphqlBasic from './plugins/with-graphql-basic'
import withGraphql from './plugins/with-graphql'
import withFramerMotionEsmodulesDisabled from './plugins/with-framer-motion-esmodules-disabled'
import { getHashicorpPackages } from './get-hashicorp-packages'

Expand Down Expand Up @@ -33,7 +33,7 @@ function withHashicorp({
return function withHashicorpInternal(nextConfig: Partial<NextConfig> = {}) {
const chain = [
withBundleAnalyzer({ enabled: process.env.ANALYZE === 'true' }),
withGraphqlBasic(),
withGraphql(),
withFramerMotionEsmodulesDisabled(),
]

Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
// Very simple plugin that loads external graphql files as strings.
// We use this in concert with the rivet data loading system.

module.exports = function withGraphQlBasic() {
return function withGraphQlBasicInternal(nextConfig = {}) {
module.exports = function withGraphQl() {
return function withGraphQlInternal(nextConfig = {}) {
return Object.assign({}, nextConfig, {
webpack(config, options) {
config.module.rules.push({
test: /\.(graphql|gql)$/,
use: [{ loader: 'raw-loader' }],
loader: 'graphql-tag/loader',
})

if (typeof nextConfig.webpack === 'function') {
Expand Down

0 comments on commit 9a33aa9

Please sign in to comment.