npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

graphql-react-admin

v0.0.6

Published

GraphQL Automatic admin panel from GraphQL schema

Downloads

14

Readme

GraphQL React Admin

Easily generate react forms for your GraphQL schema and create instant Form based GraphiQL.

Installation

npm i graphql-react-admin react react-dom @rjsf/core

Usage

FormQL

Interactive component for full GraphiQL experience using forms

import { FormQL } from 'graphql-react-admin';
import React from 'react';

const schema = `
type Query{
	listBooks: [Book!]!
	listAuthors: [Author!]!
	getBook(
		id: String
	): Book!
	getAuthor(
		id: String
	): Author!
	"""
	type object node
	"""
	getAllRentals: [RentABook!]
}

type Book{
	id: ID
	name: String!
	author: Author!
}

type Author{
	id: ID
	firstName: String!
	lastName: String!
}

"""
type object node
"""
type RentABook{
	"""
	type object node
	"""
	client: Customer!
	"""
	scalar object node
	"""
	start: Date!
	"""
	scalar object node
	"""
	end: Date
}

"""
type object node
"""
type Customer{
	"""
	String object node
	"""
	firstName: String
	"""
	String object node
	"""
	lastName: String
	"""
	ID object node
	"""
	ID: ID
}

"""
scalar object node
"""
scalar Date

type Mutation{
	createAuthor(
		author: CreateAuthorInput
	): Author!
	updateAuthor(
		author: UpdateAuthorInput
	): Author!
	updateBook(
		book: UpdateBookInput
	): Book!
	"""
	type object node
	"""
	createCustomer(
		inputNode: CreateCustomerInput
	): Customer
	"""
	type object node
	"""
	rent(
		inputNode: rentInput
	): RentABook
}

input CreateAuthorInput{
	firstName: String!
	lastName: String!
}

input UpdateAuthorInput{
	id: ID!
	firstName: String!
	lastName: String!
}

input UpdateBookInput{
	id: ID!
	name: String!
	author: String!
}

"""
input object node
"""
input CreateCustomerInput{
	"""
	String object node
	"""
	firstName: String
	"""
	String object node
	"""
	lastName: String
}

"""
input object node
"""
input rentInput{
	"""
	String object node
	"""
	customerID: String
	"""
	String object node
	"""
	bookID: String
}

input CreateBookInput{
	name: String!
	author: String!
}
schema{
	query: Query,
	mutation: Mutation
}
`;

export const App = () => {
    return (
        <div>
            <FormQL schema={schema} />
        </div>
    );
};

ZeusForm

Mighty graphql-zeus powered form with validation field generation.

  1. Generate zeus for your GraphQL schema.
  2. Import ValueTypes from generated schema
  3. You have a form with validation and full typings basing on schema and inputs
import React from 'react';
import { PaymentType, ValueTypes } from './graphql-zeus';
import { ZeusForm } from 'graphql-react-admin';
const Form = ZeusForm<ValueTypes>({ url: 'https://faker.graphqleditor.com/a-team/potus/graphql' });
const AddOrderForm = Form('AdminMutation', 'createOrder');

export const ZeusApp = () => {
    return (
        <div style={{ padding: 60 }}>
            <AddOrderForm
                formData={{
                    createOrder: {
                        refId: Math.floor(10000 * Math.random()) + '',
                        loadAddressKey: { addressKey: '123' },
                        plannedEndDate: new Date().toISOString(),
                        unloadAddressKey: { addressKey: '123' },
                    },
                }}
                onSubmit={(e) => {
                    console.log(e);
                }}
            />
        </div>
    );
};

Themes

As this form is based on @rjsf/core package it support its themes

import { withTheme } from '@rjsf/core';

export const App = () => {
    return (
        <div>
            <FormQL
                FormComponent={withTheme({
                    /* Create your theme here */
                })}
                schema={schema}
            />
        </div>
    );
};

Deps

Admin uses @rjsf/core under the hood. They have some really cool themes including fluent, antd and material-ui

Development

If you would like to develop graphql-react-admin

git clone https://github.com/graphql-editor/graphql-react-admin
cd graphql-react-admin
npm i
npm run start

Releasing

Bump version and push to develop or master to release with @latest or @beta tag.