Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

monaco-editor/monaco-graphql x GraphiQL #3234

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 1 addition & 5 deletions .browserslistrc
Original file line number Diff line number Diff line change
@@ -1,5 +1 @@
last 2 versions
Firefox ESR
not dead
not IE 11
not ios 10
defaults and supports es6-module
25 changes: 25 additions & 0 deletions .changeset/pre.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"mode": "pre",
"tag": "monaco",
"initialVersions": {
"example-graphiql-webpack": "1.1.1-alpha.8",
"example-monaco-graphql-nextjs": "0.0.0",
"example-monaco-graphql-react-vite": "0.0.0",
"example-monaco-graphql-webpack": "1.1.1",
"cm6-graphql": "0.0.9",
"codemirror-graphql": "2.0.9",
"graphiql": "3.0.5",
"@graphiql/plugin-code-exporter": "0.3.4",
"@graphiql/plugin-explorer": "0.3.4",
"@graphiql/react": "0.19.3",
"@graphiql/toolkit": "0.9.1",
"graphql-language-service": "5.1.7",
"graphql-language-service-cli": "3.3.25",
"graphql-language-service-server": "2.11.3",
"monaco-graphql": "1.3.0",
"vscode-graphql": "0.8.17",
"vscode-graphql-execution": "0.2.4",
"vscode-graphql-syntax": "1.2.2"
},
"changesets": []
}
7 changes: 7 additions & 0 deletions .changeset/soft-cars-notice.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
'graphiql': major
'@graphiql/react': major
'monaco-graphql': major
---

release `graphiql` with `monaco-editor` support
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ packages/codemirror-graphql/*.d.ts
packages/codemirror-graphql/*.map
!packages/codemirror-graphql/*.config.js

# cdn bundle build assets
packages/graphiql/index.html
packages/graphiql/dev.html
packages/graphiql/analyzer.html
Expand All @@ -50,3 +51,4 @@ packages/graphiql/*.map
packages/graphiql/cypress/screenshots/
packages/graphiql/typedoc/
packages/graphiql/webpack/
packages/graphiql/*.worker.js
25 changes: 25 additions & 0 deletions examples/graphiql-webpack/src/index.html.ejs
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<!doctype html>
<html lang="en" dir="ltr">
<head>
<meta charset="UTF-8" />
<meta
name="viewport"
content="width=device-width, initial-scale=1, shrink-to-fit=no"
/>
<title>GraphiQL Webpack Example!</title>
</head>

<body>
<style>
body {
padding: 0;
margin: 0;
min-height: 100vh;
}
#root {
height: 100vh;
}
</style>
<div id="root"></div>
</body>
</html>
2 changes: 1 addition & 1 deletion examples/graphiql-webpack/src/index.jsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import 'regenerator-runtime/runtime.js';
import 'regenerator-runtime/runtime';
import * as React from 'react';
import { createRoot } from 'react-dom/client';
import { GraphiQL } from 'graphiql';
Expand Down
84 changes: 83 additions & 1 deletion examples/graphiql-webpack/webpack.config.js
Original file line number Diff line number Diff line change
@@ -1 +1,83 @@
module.exports = require('../../resources/webpack.config');
const path = require('node:path');
const webpack = require('webpack');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const { BundleAnalyzerPlugin } = require('webpack-bundle-analyzer');
const MonacoWebpackPlugin = require('monaco-editor-webpack-plugin');

const relPath = (...args) => path.resolve(__dirname, ...args);
const rootPath = (...args) => relPath(...args);

const resultConfig = {
mode: process.env.NODE_ENV,
entry: './index.jsx',
context: rootPath('src'),
output: {
path: rootPath('dist'),
filename: '[name].js',
},
module: {
rules: [
// you can also use ts-loader of course
// i prefer to use babel-loader & @babel/plugin-typescript
// so we can experiment with how changing browserslistrc targets impacts
// monaco-graphql bundling
Comment on lines +20 to +22
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// you can also use ts-loader of course
// i prefer to use babel-loader & @babel/plugin-typescript
// so we can experiment with how changing browserslistrc targets impacts
// I prefer to use babel-loader & @babel/plugin-typescript
// Of course, you can also use ts-loader
// We can experiment to see how changing browserslistrc targets impacts

{
test: /\.(js|jsx|ts|tsx)$/,
use: [{ loader: 'babel-loader' }],
},
{
test: /\.css$/,
use: ['style-loader', 'css-loader'],
},
{
test: /\.svg$/,
use: [{ loader: 'svg-inline-loader' }],
},
{
test: /\.(woff|woff2|eot|ttf|otf)$/,
type: 'asset/resource',
},
],
},
resolve: {
extensions: ['.mjs', '.js', '.json', '.jsx', '.css', '.ts', '.tsx'],
},
plugins: [
new webpack.optimize.LimitChunkCountPlugin({
maxChunks: 1,
}),
// in order to prevent async modules for CDN builds
// until we can guarantee it will work with the CDN properly
// and so that graphiql.min.js can retain parity
new HtmlWebpackPlugin({
Comment on lines +49 to +51
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// in order to prevent async modules for CDN builds
// until we can guarantee it will work with the CDN properly
// and so that graphiql.min.js can retain parity
// This is to prevent async modules for CDN builds
// until we can guarantee it will work properly with the CDN
// and that graphiql.min.js can retain parity

template: relPath('src/index.html.ejs'),
filename: 'index.html',
}),

new MonacoWebpackPlugin({
languages: ['json', 'graphql'],
publicPath: '/',
customLanguages: [
{
label: 'graphql',
worker: {
id: 'graphql',
entry: 'monaco-graphql/esm/graphql.worker.js',
},
},
],
}),
],
};

if (process.env.ANALYZE) {
resultConfig.plugins.push(
new BundleAnalyzerPlugin({
analyzerMode: 'static',
openAnalyzer: false,
reportFilename: rootPath('build/analyzer.html'),
}),
);
}

module.exports = resultConfig;
5 changes: 3 additions & 2 deletions packages/graphiql-react/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,7 @@
"types"
],
"scripts": {
"prebuild": "rimraf dist types",
"dev": "concurrently 'tsc --emitDeclarationOnly --watch' 'vite build --watch'",
"dev": "vite build --watch",
"build": "tsc --emitDeclarationOnly && vite build"
},
"peerDependencies": {
Expand All @@ -49,6 +48,8 @@
},
"dependencies": {
"@graphiql/toolkit": "^0.9.1",
"monaco-editor": "^0.39.0",
"monaco-graphql": "^1.2.3",
"@headlessui/react": "^1.7.15",
"@radix-ui/react-dialog": "^1.0.4",
"@radix-ui/react-dropdown-menu": "^2.0.5",
Expand Down
Loading
Loading