Git Product home page Git Product logo

graphql-editor-cli's Introduction

GraphQLEditor Editor

Graph sorcery, that makes reading GraphQL schemas easier!

License stars npm npm downloads Twitter

Websiteย ย |ย ย  Docs

graphql-editor-gif

GraphQLEditor makes it easier to understand GraphQL schemas. Create a schema by using visual blocks system. GraphQL Editor will transform them into code.

With GraphQL Editor you can create visual diagrams without writing any code or present your schema in a nice way!

How it works

Create GraphQL nodes and connect them to generate a database schema. You can also use builtin text IDE with GraphQL syntax validation

๐Ÿ’ก What is GraphQL Editor?

GraphQL Editor is Graph based system for reading and designing the GraphQL schema

GraphQL Editor is a GraphQL visualizer and designer. It allows you to create and display GraphQL schemas as a visual graph.

๐Ÿš€ Features

  • Visual GraphQL Editing.
  • GraphQL Monaco based IDE
  • Selection observer. When node is clicked in visual Graph it automatically scrolls the code to the same node. When cursor is moved in code space
  • Automatically bound interfaces. When interface is implemented on type fields of the interface add to the type. If it is already implemented editing interface edits all implementing nodes
  • Writing,generating and displaying GraphQL Documentation in markdown. Generating GraphQL docs out of GraphQL descriptions in markdown
  • Comparing different versions of GraphQL schemas with special node-sort sorting nodes and its fields to show the real difference in GraphQL Schema on AST omitting line numbers

Table of contents

License

MIT

Installation

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

GraphQL SDL Editor

Usage

import React, { useState } from 'react';
import { render } from 'react-dom';
import { GraphQLEditor, PassedSchema } from 'graphql-editor';

const schemas = {
  pizza: `
type Query{
	pizzas: [Pizza!]
}
`,
  pizzaLibrary: `
type Pizza{
  name:String;
}
`,
};

export const App = () => {
  const [mySchema, setMySchema] = useState<PassedSchema>({
    code: schemas.pizza,
    libraries: schemas.pizzaLibrary,
  });
  return (
    <div
      style={{
        flex: 1,
        width: '100%',
        height: '100%',
        alignSelf: 'stretch',
        display: 'flex',
        position: 'relative',
      }}
    >
      <GraphQLEditor
        setSchema={(props) => {
          setMySchema(props);
        }}
        schema={mySchema}
      />
    </div>
  );
};

render(<App />, document.getElementById('root'));

GraphQLEditor component props

GraphQLEditor

property type description required default
schema PassedSchema value of the schema true
setSchema (props: PassedSchema, isInvalid?: boolean) => void; Function to be called when schema is set by the editor true
readonly boolean lock editing false false
diffSchemas Record<string, string> Record containing graphql schemas with "name" as a key and graphql schema as a "value" false
theme EditorTheme current theme MainTheme
routeState EditorRoutes listen to route changes. Don't bind it with routeState though! false
onStateChange ( r: EditorRoutes ) => void; on route state changed false
onTreeChange (tree: ParserTree) => void Function that could be fired if tree changes false
placeholder string placeholder - empty editor false

PassedSchema

property type description
code string value of the schema code
libraries string value of the current libraries

ActivePane

"relation" | "diagram" | "diff"

GraphQL Gql Editor

Usage

import React, { useState } from 'react';
import { render } from 'react-dom';
import { GraphQLEditor, PassedSchema } from 'graphql-editor';

const schema = `
type Query{
	pizzas: [Pizza!]
}
`;

export const App = () => {
  const [gql, setGql] = useState('');
  return ( ||
    <div
      style={{
        flex: 1,
        width: '100%',
        height: '100%',
        alignSelf: 'stretch',
        display: 'flex',
        position: 'relative',
      }}
    >
      <GraphQLGqlEditor
        gql={gql}
        setGql={(gqlString) => setGql(gqlString)}
        schema={{ code: schema }}
      />
    </div>
  );
};

render(<App />, document.getElementById('root'));

GraphQLGqlEditor component props

GraphQLEditor

property type description required default
schema PassedSchema value of the schema true
gql string value of the gql true
placeholder string placeholder - empty editor false undefined
setGql (props: PassedSchema, isInvalid?: boolean) => void; set value of the gql true undefined
readonly boolean lock editing false false
theme EditorTheme current theme false MainTheme

GraphQL Embedded Readonly Editor

If you only want to view the schema and embed it somewhere in your app you can use our embedded editor for that reason

import React from 'react';
import { EmbeddedGraphQLEditor } from 'graphql-editor';
import * as schemas from '../schema';

export const embeddedEditor = () => {
  return (
    <div
      style={{
        flex: 1,
        width: '100%',
        height: '100%',
        alignSelf: 'stretch',
        display: 'flex',
        position: 'relative',
      }}
    >
      <EmbeddedGraphQLEditor
        schema={{
          code: schemas.googleDirectionsNew,
          libraries: '',
        }}
      />
    </div>
  );
};

Support

Join our Discord Channel

Team

GraphQL Editor Website

Underlying Parsing technology

Whole graphql-editor parsing stuff is based on underlying zeus technology.

GraphQL Tutorials

Interactive GraphQL Tutorial

GraphQL Blog

Authors

graphql-editor-cli's People

Contributors

aexol avatar dennor avatar dtomart avatar taksebiegam avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

graphql-editor-cli's Issues

Add dgraph starter

It is possible to use GraphQL Editor as no-code tool for dgraph native

Store credentials and config globally

Expected Behavior

Authenticate once per account and keep credentials outside of project structure. conf seems like a reasonable library to support global user config files. It sticks to platform preferred convention by keeping configs in XDG_CONFIG_PATH on Linux, %LOCALAPPDATA% on Win, and ~/Library on macOS.

Reasoning behind that change, is to keep user actions needed to authenticate to minimum and prevent potential mistakes of pushing sensitive credential information to project repository.

Actual Behavior

.graphql-editor-auth.json is created in project directory.

Steps to Reproduce the Problem

  1. Perform any action requiring authentication

Add login command and/or document behaviour for commands requiring authentication.

Expected Behavior

Tool requires either an explicit login command or documentation on when authentication is performed.

Actual Behavior

Currently user is authenticated the moment he performs an action requiring said authentication. This behavior is not documented anywhere.

Steps to Reproduce the Problem

  1. Perform any action requiring authentication

Missing call to action when not logged in.

Expected Behavior

When performing action that requires authentication, user should be prompted to check his browser or manually visit authorize URL (for headless/misconfigured environments).

Something like:

Please check your browser or visit <URL> to login.

Actual Behavior

Program just infinitely waits for action.

Steps to Reproduce the Problem

  1. Remove credentials.
  2. Perform action requiring said credentials.

Add hot development

Add hot command. This command will:

  1. Pull the code from the microservice s3 cloud from graphql editor to temp folder somewhere
  2. Install all the packages + stucco-js
  3. Estabilish connection with pusher socket to track changes on microservices folder:
    • on each change pull the code from cloud and update the files
  4. In parallel run gecli dev inside the temp folder or run that from the code

On each change of the file, files recompile ts files and rerun stucco.

This will allow to stay with initial development inside graphql-editor and run the local server at the same time!

Add envs guard

endpoint should have guard to prevent execute him without required envs

export const getEnv = (envName: string) => {
  const envValue = process.env[envName];
  if (typeof envValue === 'undefined') {
    throw new Error(`Please define ${envName}`);
  }
  return envValue;
};

Add concurrent watcher

Many things are running in GraphQL Editor CLI project:

  • TypeScript watch
  • Stucco server
  • Update fetcher

So on every file update we should rerun stucco server. There should be also keyboard shortcut for:

  1. Refetch and update schema
  2. Recompile ts
  3. Restart Server

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.