question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Schema with multiple files

See original GitHub issue

In my case, my schema is separeted in multiple files as the image below image

Currently is possible generate a markdown when have a case like mine? I tried add multiple files as parameter, but I got error.

The solution in my case was transfer content of all the files to schema.graphql and use the graphql-markdown to generate a file.md.

My suggestion is create a possibility to this case when have a schema splited in multiple files. Make sense? It’s possible?

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:5

github_iconTop GitHub Comments

1reaction
hiagolcmcommented, May 2, 2022

I joined all .graphql files programmatically using some extra libs. And then attached it to a git hook

const fs = require('fs')

const { loadFilesSync } = require('@graphql-tools/load-files')
const { mergeTypeDefs } = require('@graphql-tools/merge')
const graphql = require('graphql')
const {
 loadSchemaJSON,
 renderSchema,
} = require('graphql-markdown')

const SCHEMA_PATH = `${__dirname}/../graphql/**/*.graphql`
const BUNDLE_PATH = `${__dirname}/../joined.graphql`
const MARKDOWN_PATH = `${__dirname}/../docs/README.md`

;(async () => {
 // Generate bundle
 const loadedFiles = loadFilesSync(SCHEMA_PATH)
 const typeDefs = mergeTypeDefs(loadedFiles)
 const printedTypeDefs = graphql.print(typeDefs)
 fs.writeFileSync(BUNDLE_PATH, printedTypeDefs)

 // Generate markdown
 fs.unlinkSync(MARKDOWN_PATH)
 const schema = await loadSchemaJSON(BUNDLE_PATH, { graphql })
 renderSchema(schema, {
   printer: (doc) => fs.appendFileSync(MARKDOWN_PATH, doc)
 })

 // Delete temp file
 fs.unlinkSync(BUNDLE_PATH)
})()

1reaction
nextdude-mdsolcommented, Apr 29, 2022

@wagnerlduarte @GabrielBarross not really, but

cat types/*.graphql | graphql-markdown /dev/stdin

might work if your system is linux or mac (has /dev/stdin). Basically, you’re limited to a single file given how graphql-markdown parses its arguments. This example combines your files and pipes the resulting output to graphql-markdown passing in dev./stdin as the file (which represents the piped input).

Read more comments on GitHub >

github_iconTop Results From Across the Web

Dealing With Multiple XML Schema Files - xFront
It is not okay to make multiple copies of a schema file and have multiple schemas reuse the multiple copies. D.xsd is placed...
Read more >
How to ingest multiple files with various schema using a single ...
How to ingest multiple files with various schema using a single Azure data Factory Copy Activity through Parametrized Datasets and Mappings.
Read more >
Multiple Schema File Syntax - Jade Software
For details about selecting multiple files to load into a JADE database, specifying the order in which the files are loaded, and then...
Read more >
Multi Schema Files Parsing in Talend - YouTube
My Complete Talend Course on Udemy: https://www.udemy.com/course/talend-d... … Show more. Show more. Chapters. View all ...
Read more >
Support for splitting Prisma schema into multiple files #2377
Prisma currently only supports one single Prisma Schema file. Developers want more flexibility for managing their Prisma Schema files.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found