-
-
Notifications
You must be signed in to change notification settings - Fork 517
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
How to use a schema instead of an introspection query in index.html? #355
Comments
Your logic is correct, but the function |
Hi. I'm sorry if I'm hijacking this issue, but I'm having the exact same problematic. It's not for a build process specifically, but I'm trying to use Voyager on a static HTML page, using an SDL string as the input. To gain access to the But when launching the page, I just have an infinitely loading screen. No errors are logged in the console, and I'm a bit at a loss as to what I'm doing wrong or how to go about debugging this. EDIT: I made a demo reproducing the issue on this repo: graphql-voyager-sdl-static-html-demo It can be seen at this URL: https://turnabout.github.io/graphql-voyager-sdl-static-html-demo/ This may not be the optimal way to go about doing it, but right now I'm just trying to get something working. I'm not able to send an introspection query, all I have access to is an SDL string just like the OP. |
I wanted to do the same thing and ran into the same problem. What helped me figure it out was looking at the demo files: https://github.com/graphql-kit/graphql-voyager/blob/main/demo/presets/swapi_introspection.json In short, the renderVoyager introspection parameter expects the actual introspection nested in a 'data' field:
|
Hi Team, first let me say what a great tool. Sorry if this belongs in the Discussions, but I didn't see any conversations there, so I am not sure if Discussions are being used.
What I am trying to do is create static documentation for our GraphQL API as part of our build and deployment process. I am using the SpectaQL tool and so far it's working great. I would also love to add an option to visualize our schema with GraphQL Voyager.
So let's make this simple. As proof of concept, I modified the index.html example in the following manner:
Where
data
is the result of executing an introspection query against our schema.Works great! But during our build process I can't execute an introspection query. The only thing I have access to is our schema file.
I read some older issues and I see this seems to be a common question. I enabled
allowToChangeSchema
and played around with the tool, so I know it's possible to use an SDL string instead of the introspection query to render the schema. But I can't figure out how to do it (my knowledge of JS is limited).I am trying to do something like this: const data = introspectionFromSchema(buildSchema(sdlText)) but it doesn't seem that
buildSchema
andintrospectionFromSchema
functions are available invoyager.standalone.js
.Are they minified? I am lost. Assuming I have
const schema = ...
how do I convert it to a JSON object representing the result of the introspection query?Thanks a lot.
The text was updated successfully, but these errors were encountered: