Skip to content

Instantly share code, notes, and snippets.

@andifalk
Last active February 14, 2024 17:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save andifalk/8d1e7470adab629df5799e0c120fefe0 to your computer and use it in GitHub Desktop.
Save andifalk/8d1e7470adab629df5799e0c120fefe0 to your computer and use it in GitHub Desktop.
Installing GraphQL Editor (Open Source)

How to set up GraphQL Editor locally

https://github.com/graphql-editor/graphql-editor

Installation

Step 1: Create react.js app with required additional dependencies

npx create-react-app graphql-editor --template typescript

Step 2: Add required dependencies

cd graphql-editor
npm i -D worker-loader css-loader file-loader webpack
npm i  graphql-editor monaco-editor @monaco-editor/react

Step 3: Replace contents in file src/App.txs

import { useState } from 'react';
import { GraphQLEditor, PassedSchema } from 'graphql-editor';
import './App.css';

export const App = () => {
  const [mySchema, setMySchema] = useState<PassedSchema>({
    code: '',
    source: "tree",
    passGraphValidation: true,
  });
  return (
    <div
      style={{
        flex: 1,
        width: '100%',
        height: '100%',
        alignSelf: 'stretch',
        display: 'flex',
        position: 'relative',
      }}
    >
      <GraphQLEditor
        setSchema={(props) => {
          setMySchema(props);
        }}
        schema={mySchema}
        path=''
      />
    </div>
  );
};

export default App;

Run the app

Just start the app using

npm start dev

Now start designing your APIs at http://localhost:3000

installed_graphql_editor

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment