• Stars
    star
    902
  • Rank 50,637 (Top 1.0 %)
  • Language
    JavaScript
  • License
    MIT License
  • Created almost 6 years ago
  • Updated over 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Explorer plugin for GraphiQL

Interactive explorer plugin for GraphiQL.

Try it live at https://www.onegraph.com/graphiql.

OneGraph provides easy, consistent access to the APIs that underlie your business--all through the power of GraphQL.

Sign up at https://www.onegraph.com.

npm version

Example usage

See the example repo for how to use OneGraph's GraphiQL Explorer in your own GraphiQL instance.

Preview

Read the rationale on the OneGraph blog.

Customizing styles

The default styling matches for the Explorer matches the default styling for GraphiQL. If you've customized your GraphiQL styling, you can customize the Explorer's styling to match.

Customizing colors

The Explorer accepts a colors prop as a map of the class names in GraphiQL's css to hex colors. If you've edited the GraphiQL class names that control colors (e.g. cm-def, cm-variable, cm-string, etc.) use those same colors in the colors map. The naming of the keys in the colors map tries to align closely with the names of the class names in GraphiQL's css (note that the Explorer can't just apply the classes because of conflicts with how the css file styles inputs).

Example style map:

<Explorer colors={{
  keyword: '#B11A04',
  // OperationName, FragmentName
  def: '#D2054E',
  // FieldName
  property: '#1F61A0',
  // FieldAlias
  qualifier: '#1C92A9',
  // ArgumentName and ObjectFieldName
  attribute: '#8B2BB9',
  number: '#2882F9',
  string: '#D64292',
  // Boolean
  builtin: '#D47509',
  // Enum
  string2: '#0B7FC7',
  variable: '#397D13',
  // Type
  atom: '#CA9800',
}} />

Customizing arrows and checkboxes

The explorer accepts props for setting custom checkboxes (for leaf fields) and arrows (for object fields).

The props are arrowOpen, arrowClosed, checkboxChecked, and checkboxUnchecked. You can pass any react node for those props.

The defaults are

arrowOpen

  <svg width="12" height="9">
    <path fill="#666" d="M 0 2 L 9 2 L 4.5 7.5 z" />
  </svg>

arrowClosed

  <svg width="12" height="9">
    <path fill="#666" d="M 0 0 L 0 9 L 5.5 4.5 z" />
  </svg>

checkboxChecked

  <svg
    style={{marginRight: '3px', marginLeft: '-3px'}}
    width="12"
    height="12"
    viewBox="0 0 18 18"
    fill="none"
    xmlns="http://www.w3.org/2000/svg">
    <path
      d="M16 0H2C0.9 0 0 0.9 0 2V16C0 17.1 0.9 18 2 18H16C17.1 18 18 17.1 18 16V2C18 0.9 17.1 0 16 0ZM16 16H2V2H16V16ZM14.99 6L13.58 4.58L6.99 11.17L4.41 8.6L2.99 10.01L6.99 14L14.99 6Z"
      fill="#666"
    />
  </svg>

checkboxUnchecked

  <svg
    style={{marginRight: '3px', marginLeft: '-3px'}}
    width="12"
    height="12"
    viewBox="0 0 18 18"
    fill="none"
    xmlns="http://www.w3.org/2000/svg">
    <path
      d="M16 2V16H2V2H16ZM16 0H2C0.9 0 0 0.9 0 2V16C0 17.1 0.9 18 2 18H16C17.1 18 18 17.1 18 16V2C18 0.9 17.1 0 16 0Z"
      fill="#CCC"
    />
  </svg>

Customizing the buttons to create new operations

You can modify the styles for the buttons that allow you to create new operations.

Pass the styles prop when you create the component. It's an object with two keys, explorerActionsStyle and buttonStyle.

Example styles map:

<Explorer
  styles={{
    buttonStyle: {
      fontSize: '1.2em',
      padding: '0px',
      backgroundColor: 'white',
      border: 'none',
      margin: '5px 0px',
      height: '40px',
      width: '100%',
      display: 'block',
      maxWidth: 'none',
    },

    explorerActionsStyle: {
      margin: '4px -8px -8px',
      paddingLeft: '8px',
      bottom: '0px',
      width: '100%',
      textAlign: 'center',
      background: 'none',
      borderTop: 'none',
      borderBottom: 'none',
    },
  }}
/>

More Repositories

1

graphiql-explorer-example

Example of OneGraph's GraphiQL Explorer in action
JavaScript
149
star
2

oneblog

Build a blog backed by GitHub issues
HTML
92
star
3

graphiql-code-exporter

JavaScript
79
star
4

onegraph-examples

Examples big and small of how to use OneGraph in modern applications
JavaScript
52
star
5

graphiql-with-extensions

A convenience package for those who just want a single-line drop-in replacement for existing GraphiQL usage
JavaScript
26
star
6

graphql-codex

Static GraphQL schema reference
JavaScript
23
star
7

onegraph-client

JavaScript
20
star
8

youtube-captions-helper

JavaScript
16
star
9

onegraph-blog

HTML
13
star
10

OneProfile

Example app bringing life to a Youtube video via OneGraph
OCaml
9
star
11

onegraph-changelog

Product Changelog for OneGraph using Persisted Queries
HTML
8
star
12

essay.dev

Create an issue on this repo to publish to your very own blog at <your-github-username>.essay.dev
8
star
13

auth-guardian-next-js-starterkit

JavaScript
7
star
14

graphiql-code-exporter-example

Example usage of OneGraph's open-source GraphiQL Code Exporter
JavaScript
7
star
15

onegraph-apollo-server-auth-example

An example repository showing how to implement both authentication and permissions quickly in your Apollo server APIs with OneGraph's AuthGuardian.
JavaScript
5
star
16

authguardian-nextjs-starter

JavaScript
4
star
17

graphql-docs-netlify

OneGraph's Schema Reference with support for deploy to Netlify
JavaScript
4
star
18

stripe-examples

Example components for accessing Stripe data with OneGraph
CSS
3
star
19

json-atd

JSON->ATD converter, written in CLJS
Clojure
2
star
20

onegraph-express-jwt-example

An example showing how to secure your express apps with OneGraph JWTs
JavaScript
2
star
21

authguardian-react-starter

A lightweight example of how to use AuthGuardian with React
JavaScript
2
star
22

onegraph-meetup-plugin

Display Upcoming Meetup Events
JavaScript
1
star