This repository has been archived by the owner on Sep 13, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 43
doc: auto gen api #33
Merged
Merged
Changes from 1 commit
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
#!/usr/bin/env bash | ||
|
||
BASEDIR=$(dirname "$0") | ||
|
||
function check() { | ||
if ! type "$1" > /dev/null; then | ||
echo "$1 is required, install first $2" | ||
echo $2 | ||
exit 1 | ||
fi | ||
} | ||
|
||
check node | ||
check graphql-markdown "run npm install graphql-markdown --global" | ||
|
||
endpoint="http://127.0.0.1:8000/graphql" | ||
if [ ! -z "$1" ]; then | ||
endpoint=$1 | ||
fi | ||
|
||
res_code=$(curl --write-out %{http_code} --silent --output /dev/null \ | ||
-X POST -d '{"query":"query { getLatestEpoch { header { epochId }}}"}' \ | ||
$endpoint) | ||
|
||
if [ $res_code -ne 200 ]; then | ||
echo "$endpoint GraphQL endpoint request failed" | ||
echo "start API server at first or use the custom endpoint make doc-api http://x.x.x.x:8000/graphql" | ||
exit 1; | ||
fi | ||
|
||
prologue=" | ||
>[GraphQL](https://graphql.org) is a query language for APIs and a runtime for fulfilling those queries with your existing data. | ||
GraphQL provides a complete and understandable description of the data in your API, | ||
gives clients the power to ask for exactly what they need and nothing more, | ||
makes it easier to evolve APIs over time, and enables powerful developer tools. | ||
Muta has embeded a [Graph*i*QL](https://github.com/graphql/graphiql) for checking and calling API. Started a the Muta | ||
node, and then try open http://127.0.0.1:8000/graphiql in the browser. | ||
" | ||
|
||
graphql-markdown $endpoint --title "Muta GraphQL API" --prologue "$prologue" > $BASEDIR/../graphql_api.md |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a hash, not a mercke root.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, I have make the description more clearly now