Problem with Docker
Closed this issue · 6 comments
I'm trying to use docker to generate the files, but it seens meow
have some issues by parsing the cmd line arguments.
FROM node:15.1.0-alpine3.10
RUN npm -g install graphqlviz
RUN graphqlviz ausheuashe
That is expected to say that file ausheuashe
does not exists, but the help message is shown instead. I can also put anything as argument it will always show the help.
------
> [stage-1 4/6] RUN graphqlviz ausheuashe:
#8 2.092
#8 2.092 GraphQL Server CLI visualizer
#8 2.092
#8 2.092 Options:
#8 2.092 -t --theme path to theme overrides
#8 2.092 --print-theme print default theme to stdout
#8 2.092 -v --verbose print introspection result
#8 2.092 -a --auth set Authorization header for graphql server
#8 2.092
#8 2.092 Usage:
#8 2.092 $ graphqlviz [url]
#8 2.092 Renders dot schema from [url] endpoint
#8 2.092
#8 2.092 Examples:
#8 2.092 $ graphqlviz https://localhost:3000 | dot -Tpng -o graph.png
#8 2.092 $ graphqlviz https://example.com/graphql -a "Bearer xxxxx" | dot -Tpng -o graph.png
#8 2.092 $ graphqlviz https://swapi.apis.guru | dot -Tpng | open -f -a Preview
#8 2.092 $ graphqlviz path/to/schema.json | dot -Tpng | open -f -a Preview
#8 2.092 $ graphqlviz path/to/schema.graphql | dot -Tpng | open -f -a Preview
#8 2.092 $ graphqlviz --print-theme > theme.json
#8 2.092 $ graphqlviz https://localhost:3000 -t theme.json | dot -Tpng | open -f -a Preview
#8 2.092 $ graphqlviz schema.json --theme.header.invert=true | dot -Tpng > schema.png
#8 2.092
------
That also happens if I create a bash script and put the graphqlviz command inside.
I believe the issue is that Docker build RUN
commands are not interactive or tty sessions. Currently, the graphqlviz cli assumes that if it is not tty then the input will be piped to stdin. Running it interactively within a docker container (docker run -it ...
) should work fine.
https://github.com/sheerun/graphqlviz/blob/master/cli.js#L107
Well, I can't run docker run because its a image build process ( I generate the markdown files for a documentation ) :(
Why it is reading the stdin since all arguments are coming from the command line?
That "feature" is there because it is sometimes useful to pipe from curl or similar for graphql endpoints that require authentication or which nest the introspection data somewhere in the response.
Sure, but why is exiting the program when no stdin is used? 🤔
It exits because stdin closes since it's not actually being piped to. As a workaround you could pipe the contents of your file using cat or similar.
As per #34 there is now an error message when run without a tty and nothing is passed to stdin to make this easier to debug