Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed introspection query to new, post v14 version #15

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
135 changes: 70 additions & 65 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,66 +1,71 @@
{
"name": "graphql-docs",
"version": "0.2.0",
"description": "Dynamic documentation for GraphQL endpoints",
"main": "dist/graphql-docs.js",
"author": "Magnus Hallin <[email protected]>",
"license": "SEE LICENSE IN LICENSE",
"files": [
"dist/",
"lib/",
"README.rst",
"LICENSE"
],
"bin": {
"graphql-docs-gen": "lib/generator.js"
},
"scripts": {
"test": "echo 'No tests yet :-('",
"lint": "./node_modules/.bin/eslint src",
"flow": "./node_modules/.bin/flow check",
"prepublish": "./scripts/build.sh"
},
"keywords": ["graphql", "react", "docs", "documentation"],
"homepage": "https://github.com/mhallin/graphql-docs",
"repository": {
"type": "git",
"url": "https://github.com/mhallin/graphql-docs.git"
},
"bugs": {
"url": "https://github.com/mhallin/graphql-docs/issues"
},
"engines": {
"node": ">= 4.4.0"
},
"peerDependencies": {
"react": "^15.0.1",
"react-dom": "^15.0.1"
},
"dependencies": {
"marked": "^0.3.5",
"request": "^2.74.0",
"yargs": "^5.0.0"
},
"devDependencies": {
"babel-core": "^6.7.7",
"babel-cli": "^6.7.7",
"babel-eslint": "^6.0.4",
"babel-loader": "^6.2.4",
"babel-plugin-contracts": "^1.1.1",
"babel-plugin-transform-flow-strip-types": "^6.7.0",
"babel-preset-es2015": "^6.6.0",
"babel-preset-react": "^6.5.0",
"babel-preset-stage-0": "^6.5.0",
"css-loader": "^0.25.0",
"eslint": "^3.5.0",
"eslint-plugin-flowtype": "^2.4.0",
"eslint-plugin-react": "^6.2.2",
"expose-loader": "^0.7.1",
"flow-bin": "^0.32.0",
"postcss-cssnext": "^2.5.2",
"postcss-loader": "^0.13.0",
"raw-loader": "^0.5.1",
"style-loader": "^0.13.1",
"webpack": "^1.13.0"
}
}
"name": "graphql-docs",
"version": "0.2.1",
"description": "Dynamic documentation for GraphQL endpoints",
"main": "dist/graphql-docs.js",
"author": "Magnus Hallin <[email protected]>",
"license": "SEE LICENSE IN LICENSE",
"files": [
"dist/",
"lib/",
"README.rst",
"LICENSE"
],
"bin": {
"graphql-docs-gen": "lib/generator.js"
},
"scripts": {
"test": "echo 'No tests yet :-('",
"lint": "./node_modules/.bin/eslint src",
"flow": "./node_modules/.bin/flow check",
"prepublish": "./scripts/build.sh"
},
"keywords": [
"graphql",
"react",
"docs",
"documentation"
],
"homepage": "https://github.com/mhallin/graphql-docs",
"repository": {
"type": "git",
"url": "https://github.com/mhallin/graphql-docs.git"
},
"bugs": {
"url": "https://github.com/mhallin/graphql-docs/issues"
},
"engines": {
"node": ">= 4.4.0"
},
"peerDependencies": {
"react": "^15.0.1",
"react-dom": "^15.0.1"
},
"dependencies": {
"marked": "^0.3.5",
"request": "^2.74.0",
"yargs": "^5.0.0"
},
"devDependencies": {
"babel-core": "^6.7.7",
"babel-cli": "^6.7.7",
"babel-eslint": "^6.0.4",
"babel-loader": "^6.2.4",
"babel-plugin-contracts": "^1.1.1",
"babel-plugin-transform-flow-strip-types": "^6.7.0",
"babel-preset-es2015": "^6.6.0",
"babel-preset-react": "^6.5.0",
"babel-preset-stage-0": "^6.5.0",
"css-loader": "^0.25.0",
"eslint": "^3.5.0",
"eslint-plugin-flowtype": "^2.4.0",
"eslint-plugin-react": "^6.2.2",
"expose-loader": "^0.7.1",
"flow-bin": "^0.32.0",
"postcss-cssnext": "^2.5.2",
"postcss-loader": "^0.13.0",
"raw-loader": "^0.5.1",
"style-loader": "^0.13.1",
"webpack": "^1.13.0"
}
}
11 changes: 9 additions & 2 deletions src/components/SchemaDocsView.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@

import React from 'react';

import { Schema, Type, ObjectType, InterfaceType, EnumType, ScalarType, InputObjectType } from '../model';
import { Schema, Type, ObjectType, InterfaceType, EnumType, ScalarType, InputObjectType, UnionType } from '../model';
import { getReferencesInSchema } from '../schemaWalker';

import { ObjectDocsView, InterfaceDocsView, EnumDocsView, ScalarDocsView, InputObjectDocsView } from './TypeDocsViews';
import { ObjectDocsView, InterfaceDocsView, EnumDocsView, ScalarDocsView, InputObjectDocsView, UnionDocsView } from './TypeDocsViews';

import * as StyleSheet from './SchemaDocsView.css';

Expand All @@ -27,6 +27,13 @@ export class SchemaDocsView extends React.Component {
titleOverride={this.titleOverrideFor(t)}
/>);
}
if (t instanceof UnionType) {
components.push(
<UnionDocsView
key={t.name}
type={t}
/>);
}
if (t instanceof InterfaceType) {
components.push(
<InterfaceDocsView
Expand Down
37 changes: 36 additions & 1 deletion src/components/TypeDocsViews.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import React from 'react';

import { ObjectType, InterfaceType, EnumType, ScalarType, InputObjectType, Field, TypeRef, EnumValue } from '../model';
import { ObjectType, InterfaceType, EnumType, ScalarType, InputObjectType, Field, TypeRef, EnumValue, UnionType } from '../model';

import { DescriptionView } from './DescriptionView';
import { FieldView } from './FieldView';
Expand Down Expand Up @@ -84,6 +84,22 @@ export class ScalarDocsView extends React.Component {
);
}
}
export class UnionDocsView extends React.Component {
props: {
type: UnionType,
};

render() {
const type = this.props.type;
return (
<div className={StyleSheet.type}>
{renderTitle(type.name)}
{renderDescription(type.description)}
{renderPossibleTypes(type.possibleTypes)}
</div>
);
}
}

export class InputObjectDocsView extends React.Component {
props: {
Expand Down Expand Up @@ -179,7 +195,26 @@ function renderImplementors(possibleTypes: Array<TypeRef>) {
</div>
);
}
function renderPossibleTypes(possibleTypes: Array<TypeRef>) {
if (!possibleTypes.length) {
return null;
}

return (
<div>
<div className={StyleSheet.subHeading}>
Possible Types
</div>

<ul className={StyleSheet.interfacesList}>
{possibleTypes.map((r, i) =>
<li key={i}>
<TypeRefView key={i} typeRef={r} />
</li>)}
</ul>
</div>
);
}
function renderEnumValues(enumValues: Array<EnumValue>) {
if (!enumValues.length) {
return null;
Expand Down
133 changes: 70 additions & 63 deletions src/introspectionQuery.txt
Original file line number Diff line number Diff line change
@@ -1,86 +1,93 @@
query IntrospectionQuery {
__schema {
queryType {
name
}
mutationType {
name
}
subscriptionType {
name
}
types {
...FullType

query IntrospectionQuery {
__schema {
queryType { name }
mutationType { name }
subscriptionType { name }
types {
...FullType
}
directives {
name
description
locations
args {
...InputValue
}
}
}
}
directives {

fragment FullType on __Type {
kind
name
description
fields(includeDeprecated: true) {
name
description
args {
...InputValue
}
onOperation
onFragment
onField
type {
...TypeRef
}
isDeprecated
deprecationReason
}
}
}

fragment FullType on __Type {
kind
name
description
fields(includeDeprecated: true) {
name
description
args {
inputFields {
...InputValue
}
type {
interfaces {
...TypeRef
}
enumValues(includeDeprecated: true) {
name
description
isDeprecated
deprecationReason
}
possibleTypes {
...TypeRef
}
isDeprecated
deprecationReason
}
inputFields {
...InputValue
}
interfaces {
...TypeRef
}
enumValues(includeDeprecated: true) {

fragment InputValue on __InputValue {
name
description
isDeprecated
deprecationReason
}
possibleTypes {
...TypeRef
}
}

fragment InputValue on __InputValue {
name
description
type {
...TypeRef
type { ...TypeRef }
defaultValue
}
defaultValue
}

fragment TypeRef on __Type {
kind
name
ofType {
kind
name
ofType {
fragment TypeRef on __Type {
kind
name
ofType {
kind
name
ofType {
kind
name
ofType {
kind
name
ofType {
kind
name
ofType {
kind
name
ofType {
kind
name
ofType {
kind
name
}
}
}
}
}
}
}
}
}
}


Loading