GithubHelp home page GithubHelp logo

graphpql / graphpinator-printer Goto Github PK

View Code? Open in Web Editor NEW
3.0 2.0 2.0 359 KB

:zap::globe_with_meridians::zap: Schema printing visitor for GraPHPinator typesystem.

Home Page: https://github.com/graphpql

License: MIT License

PHP 97.11% SCSS 2.89%
graphql graphql-php php

graphpinator-printer's Introduction

GraPHPinator Printer PHP codecov

โšก๐ŸŒโšก Schema printing visitor for GraPHPinator typesystem.

Introduction

This library allows printing of the GraphQL schema into human-readable format. It supports multiple output formats and ordering options.

Installation

Install package using composer

composer require infinityloop-dev/graphpinator-printer

How to use

Usage of this library is very simple.

$schema; // instance of \Graphpinator\Typesystem\Schema
$printer = new \Graphpinator\Printer\Printer();

echo $printer->printSchema($schema);

Advanced configiration options (see description below)

$schema; // instance of \Graphpinator\Typesystem\Schema
$printer = new \Graphpinator\Printer\Printer(
    new \Graphpinator\Printer\HtmlVisitor( // different format
        new \Graphpinator\Printer\ImplicitInheritanceFieldCollector(), // enable implicit inheritance
    ),
    new \Graphpinator\Printer\TypeKindSorter(), // different sorter
);

echo $printer->printSchema($schema);

Format

It is possible to implement additional printing mechanisms for various output formats. This is done by implementing \Graphpinator\Printer\PrintComponentVisitor and passing an instance to Printer as first constructor argument.

Implementations provided by this library:

  • TextVisitor (default) - standard mechanism which creates text output
  • HtmlVisitor - mechanism which creates structured HTML code (there is also a SCSS bundled in the theme folder and compiled CSS in build folder)

Implicit inheritance

Both formatters support Implicit inheritance RFC - option to exclude fields inherited from parent interface. In order to enable implicit inheritance, it is needed to pass different FieldCollector strategy to TextVisitor or HtmlVisitor.

Strategies provided by this library:

  • AllFieldCollector (default) - standard strategy to print all fields
  • ImplicitInheritanceFieldCollector - strategy to leverage Implicit inheritance RFC, inherited fields which remained the same are excluded

Order of types

It is possible to change the order of types/directives in output. This is done by implementing \Graphpinator\Printer\Sorter and passing an instance to Printer as second constructor argument.

Implementations provided by this library:

  • AlphabeticalSorter (default) - sorts types and directives alphabetically
  • TypeKindSorter - sorts types by their TypeKind (and then alphabetically) - interfaces first, then object types, then unions, ..., directives last

graphpinator-printer's People

Contributors

honzabejvl avatar peldax avatar vossik avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

vossik honzabejvl

graphpinator-printer's Issues

CommonMark support

Specs explicitly permit descriptions to be formatted using CommonMark (as specified by CommonMark).

  • Add support in HTML printer to print descriptions accordingly.
  • Consider whether this should be handled or ignored in Text printer.

HtmlVisitor

Print html structure instead of plain text.

  • html classes for flexible styling
  • typenames and directive names as anchor links
  • typenames and directive names with description in title
  • directiveusage arguments with description in title

SCSS

  • Transfer stylesheets into SCSS.
  • Save colors into variables so that theme is changed only by including other set of variables.
  • Create github action which compiles scss into minified css.

Html improvements

  • line numbers #7
  • brace matching
  • floating buttons in right upper corner to #8
    • go to top
    • go to query root type
    • go to mutation root type (if available)
    • go to subscription root type (if available)
  • button in each section to copy link to that section (similiar to headings in markdown) #10

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.