-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
Signed-off-by: Lee Calcote <lee.calcote@layer5.io>
- Loading branch information
There are no files selected for viewing
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
# frozen_string_literal: true | ||
# require './helper' | ||
require "haml" | ||
module Graphql | ||
module Docs | ||
# This is a custom verion of Gitlab renderer for graphql-docs for Meshery. | ||
# Uses HAML templates to parse markdown and generate .md files. | ||
# It uses graphql-docs helpers and schema parser, more information in https://github.com/gjtorikian/graphql-docs. | ||
# | ||
# Arguments: | ||
# schema - the GraphQL schema definition. | ||
# output_dir: The folder where the markdown files will be saved | ||
# template: The path of the haml template to be parsed | ||
class Renderer | ||
include Graphql::Docs::Helper | ||
|
||
attr_reader :schema | ||
|
||
def initialize(schema, output_dir, template) | ||
@output_dir = output_dir | ||
@template = template | ||
@schema = schema | ||
@layout = Haml::Engine.new(File.read(template)) | ||
@parsed_schema = GraphQLDocs::Parser.new(schema, {}).parse | ||
@seen = Set.new | ||
end | ||
|
||
def contents | ||
# Render and remove an extra trailing new line | ||
@contents ||= @layout.render(self).sub!(/\n(?=\Z)/, '') | ||
end | ||
|
||
def write | ||
filename = File.join(@output_dir, 'graphql-api-reference.md') | ||
|
||
FileUtils.mkdir_p(@output_dir) | ||
File.write(filename, contents) | ||
end | ||
|
||
private | ||
|
||
def seen_type?(name) | ||
@seen.include?(name) | ||
end | ||
|
||
def seen_type!(name) | ||
@seen << name | ||
end | ||
end | ||
end | ||
end |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,173 @@ | ||
-# haml-lint:disable UnnecessaryStringOutput | ||
= auto_generated_comment | ||
|
||
:plain | ||
Self-generated API documentation for Meshery's GraphQL API. The API can be explored interactively using the [GraphQL Playground](./extensibility). Documentation is generated from Meshery's GraphQL schema. Each table below documents a GraphQL type. | ||
|
||
WARNING: | ||
Fields that are deprecated are marked with **{warning-solid}**. | ||
|
||
<!-- vale off --> | ||
\ | ||
|
||
:plain | ||
## `Query` type | ||
|
||
The `Query` type contains the API's top-level entry points for all executable queries. | ||
\ | ||
|
||
- fields_of('Query').each do |field| | ||
= render_full_field(field, heading_level: 3, owner: 'Query') | ||
\ | ||
|
||
:plain | ||
## `Mutation` type | ||
|
||
The `Mutation` type contains all the mutations you can execute. | ||
|
||
All mutations receive their arguments in a single input object named `input`. | ||
|
||
\ | ||
|
||
- mutations.each do |field| | ||
= render_full_field(field, heading_level: 3, owner: 'Mutation') | ||
\ | ||
|
||
|
||
:plain | ||
## `Subscription` type | ||
|
||
The `Subscription` type contains all the Subscriptions you can listen to. | ||
|
||
|
||
\ | ||
|
||
|
||
- subscriptions.each do |field| | ||
= render_full_field(field, heading_level: 3, owner: 'Subscription') | ||
\ | ||
|
||
:plain | ||
## Object types | ||
|
||
Object types represent the resources that the Meshery GraphQL API can return. | ||
They contain _fields_. Each field has its own type, which will either be one of the | ||
basic GraphQL [scalar types](https://graphql.org/learn/schema/#scalar-types) | ||
(e.g.: `String` or `Boolean`) or other object types. Fields may have arguments. | ||
Fields with arguments are exactly like top-level queries, and are listed beneath | ||
the table of fields for each object type. | ||
|
||
For more information, see | ||
[Object Types and Fields](https://graphql.org/learn/schema/#object-types-and-fields) | ||
on `graphql.org`. | ||
\ | ||
|
||
- object_types.each do |type| | ||
= render_name_and_description(type) | ||
\ | ||
= render_object_fields(type[:fields], owner: type) | ||
\ | ||
|
||
:plain | ||
## Enumeration types | ||
|
||
Also called _Enums_, enumeration types are a special kind of scalar that | ||
is restricted to a particular set of allowed values. | ||
|
||
For more information, see | ||
[Enumeration Types](https://graphql.org/learn/schema/#enumeration-types) | ||
on `graphql.org`. | ||
\ | ||
|
||
- enums.each do |enum| | ||
= render_name_and_description(enum) | ||
\ | ||
~ "| Value | Description |" | ||
~ "| ----- | ----------- |" | ||
- enum[:values].each do |value| | ||
= render_enum_value(enum, value) | ||
\ | ||
|
||
:plain | ||
## Scalar types | ||
|
||
Scalar values are atomic values, and do not have fields of their own. | ||
Basic scalars include strings, boolean values, and numbers. This schema also | ||
defines various custom scalar values, such as types for times and dates. | ||
|
||
This schema includes custom scalar types for identifiers, with a specific type for | ||
each kind of object. | ||
|
||
For more information, read about [Scalar Types](https://graphql.org/learn/schema/#scalar-types) on `graphql.org`. | ||
\ | ||
|
||
- graphql_scalar_types.each do |type| | ||
= render_name_and_description(type) | ||
\ | ||
|
||
-# Current GraphQL is not using Abstract Types. Can be uncommented for future use. | ||
-# :plain | ||
-# ## Abstract types | ||
-# Abstract types (unions and interfaces) are ways the schema can represent | ||
-# values that may be one of several concrete types. | ||
-# - A [`Union`](https://graphql.org/learn/schema/#union-types) is a set of possible types. | ||
-# The types might not have any fields in common. | ||
-# - An [`Interface`](https://graphql.org/learn/schema/#interfaces) is a defined set of fields. | ||
-# Types may `implement` an interface, which | ||
-# guarantees that they have all the fields in the set. A type may implement more than | ||
-# one interface. | ||
-# See the [GraphQL documentation](https://graphql.org/learn/) for more information on using | ||
-# abstract types. | ||
-# \ | ||
-# :plain | ||
-# ### Unions | ||
-# \ | ||
-# - graphql_union_types.each do |type| | ||
-# = render_name_and_description(type, level: 4) | ||
-# \ | ||
-# One of: | ||
-# \ | ||
-# - type[:possible_types].each do |member| | ||
-# = render_union_member(member) | ||
-# \ | ||
-# :plain | ||
-# ### Interfaces | ||
-# \ | ||
-# - interfaces.each do |type| | ||
-# = render_name_and_description(type, level: 4) | ||
-# \ | ||
-# Implementations: | ||
-# \ | ||
-# - type[:implemented_by].each do |type_name| | ||
-# ~ "- [`#{type_name}`](##{type_name.downcase})" | ||
-# \ | ||
-# = render_object_fields(type[:fields], owner: type, level_bump: 1) | ||
-# \ | ||
:plain | ||
## Input types | ||
|
||
Types that may be used as arguments (all scalar types may also | ||
be used as arguments). | ||
|
||
Only general use input types are listed here. For mutation input types, | ||
see the associated mutation type above. | ||
|
||
For more information, read about [Scalar Types](https://graphql.org/learn/schema/#input-types) on `graphql.org`. | ||
|
||
\ | ||
|
||
- input_types.each do |type| | ||
= render_name_and_description(type) | ||
\ | ||
= render_argument_table(3, type[:input_fields], type[:name]) | ||
\ |