Giter Club home page Giter Club logo

Comments (3)

edno avatar edno commented on May 18, 2024

Hi @GuiHash

That's definitively something I have missed when refactoring the schema loaders. Much needed.
I don't see a way to do it without a change in the code. But, a quick way to do it would be to add an optional parameter loaderOptions (default = undefined) that accepts any object type (JSON format), then we can pass it directly to loadSchema() in generateDocFromSchema():

const schema = await loadSchema(
  schemaLocation,
  { loaders: getDocumentLoaders(loaders), }, 
  loaderOptions
);

And enhancing the plugin config loaders format to:

type className = string; // UrlLoader

type moduleName = string; // "@graphql-tools/url-loader"
+ type moduleOptions = { [option: string]: any };
+ type module = { 
+   module: moduleName, 
+   options: moduleOptions | undefined 
+ }

type loaders = {
-  [className: className]: moduleName
+  [className: className]: moduleName | module
}

Please go ahead and submit a PR 🚀

from graphql-markdown.

edno avatar edno commented on May 18, 2024

Released in 1.5.3

from graphql-markdown.

chmanie avatar chmanie commented on May 18, 2024

Hey! I'm sorry to revive this, but I don't really understand the implementation there. It seems all the options passed are moved to an object called loaderOptions which is then passed as is into the options that the graphql-tools loader takes. This is how the options look like then:

{
  loaders: [ UrlLoader {} ],
  loaderOptions: { headers: { 'x-api-key': 'xxx' } },
  filterKinds: [ 'OperationDefinition', 'FragmentDefinition' ],
  ignore: [],
  cache: {},
  cwd: '/home/chris/dev/colony/docs',
  sort: true
}

Though I think the loaderOptions need to be merged into this object, not included. Or am I doing anything horribly wrong?

EDIT: It might be a regression. Here's the original PR which merges the loaderOptions:

https://github.com/GuiHash/graphql-markdown/blob/e05985ef57b060dd785db3a02258276247beadc4/src/lib/generator.js#L25-L28

Here's the current code which just passes it in:

const loaders = getDocumentLoaders(loadersList);
const schema = await loadSchema(schemaLocation, loaders);

from graphql-markdown.

Related Issues (20)

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.