Skip to content

Commit

Permalink
Merge branch 'master' of github.com:teleniasoftware/graphql-markdown
Browse files Browse the repository at this point in the history
  • Loading branch information
exogen committed Aug 27, 2024
2 parents 5314a65 + 0e3e443 commit 1a34f79
Showing 1 changed file with 28 additions and 1 deletion.
29 changes: 28 additions & 1 deletion src/renderSchema.js
Original file line number Diff line number Diff line change
Expand Up @@ -132,8 +132,16 @@ function renderSchema(schema, options) {
const mutationType = schema.mutationType
const mutation =
mutationType && types.find((type) => type.name === schema.mutationType.name)
const subscriptionType = schema.subscriptionType
const subscription =
subscriptionType &&
types.find((type) => type.name === schema.subscriptionType.name)
const objects = types.filter(
(type) => type.kind === 'OBJECT' && type !== query && type !== mutation
(type) =>
type.kind === 'OBJECT' &&
type !== query &&
type !== mutation &&
type !== subscription
)
const inputs = types.filter((type) => type.kind === 'INPUT_OBJECT')
const enums = types.filter((type) => type.kind === 'ENUM')
Expand Down Expand Up @@ -165,6 +173,9 @@ function renderSchema(schema, options) {
if (mutation) {
printer(' * [Mutation](#mutation)')
}
if (subscription) {
printer(' * [Subscription](#subscription)')
}
if (objects.length) {
printer(' * [Objects](#objects)')
objects.forEach((type) => {
Expand Down Expand Up @@ -227,6 +238,22 @@ function renderSchema(schema, options) {
})
}

if (subscription) {
printer(
`\n${'#'.repeat(headingLevel + 1)} Subscription${
subscription.name === 'Subscription'
? ''
: ' (' + subscription.name + ')'
}`
)
renderObject(subscription, {
skipTitle: true,
headingLevel,
printer,
getTypeURL,
})
}

if (objects.length) {
printer(`\n${'#'.repeat(headingLevel + 1)} Objects`)
objects.forEach((type) =>
Expand Down

0 comments on commit 1a34f79

Please sign in to comment.