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.

JSON Schema input crashes on latest version

See original GitHub issue

Hello,

I’ve created a schema.json using the introspection query shown by the documentation. However, when running the script to create the documentation page, I hit an issue right away:

Cannot read property '__schema' of undefined

A closer look at lib/schema-loader/json.js shows this:

    try {
        var schemaPath = path_1.resolve(options.schemaFile);
        var introspection = require(schemaPath);
        return Promise.resolve(introspection.data.__schema);
    }

Why is there an expectation of a data field in the introspected schema.json file? I am able to generate a documentation page by removing the data field. But, I would like to know why the data field was put in the first place. I’m not sure if there are grave consequences to doing this. If this is an uncaught issue, I would be happy to open a PR 😄

Thanks!

Issue Analytics

  • State:open
  • Created 5 years ago
  • Reactions:11
  • Comments:5

github_iconTop GitHub Comments

1reaction
mbao01commented, Nov 6, 2019

@ayyazdaniaryan Any updates on that PR? I’m willing to help with it.

0reactions
chrisaecommented, Nov 5, 2019

Usually one would write the data as a JSON but it looks like the pure introspection result is used here. This works for me using schema.json:

const fs = require('fs');
const { buildSchema, graphqlSync, introspectionQuery } = require("graphql");

const schemaString = ''; // your SDL as a string, e.g. read schema.graphql
const graphqlSchemaObj = buildSchema(schemaString);
const result = graphqlSync(graphqlSchemaObj, introspectionQuery);
fs.writeFileSync("./schema.json", JSON.stringify(result, null, 2));

I’m putting the result into JSON.stringify, not result.data.

And execute:

 graphdoc -s ./schema.json -o ./doc/schema
Read more comments on GitHub >

github_iconTop Results From Across the Web

Rider crashes when custom JSON schema mapping for Azure ...
Rider crashes when custom JSON schema mapping for Azure Devops organization is specified : IDEA-288613.
Read more >
Seggregation of Json Schema Validation and Json Validation
I have a use case where I will take a json-schema as input, validate it, then keep in my system. Later I will...
Read more >
Release notes for SQL Server Management Studio (SSMS)
Selecting the Design option for a view that references a table using spatial data causes SSMS to crash. Use T-SQL to make changes...
Read more >
JSON Schema Serializer and Deserializer
json.schema.spec.version Indicates the specification version to use for JSON schemas ... The current JSON Schema specific producer does not show a > prompt, ......
Read more >
Specification - JSON Schema
The current version is 2020-12! The previous version was 2019-09. Specification documents #. See also the release notes / change log (Work in...
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