All WAPM services (accessible via both the registry frontend wapm.io and the CLI client wapm-cli) use the WAPM GraphQL API to interact with and retrieve data from the WAPM Registry.
GraphQL 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.
If you want to learn more about GraphQL, please visit the official Website: GraphQL.orgβ
The WAPM GraphQL API (and the GraphiQL IDE) can be accessed here:
βWebAssembly.sh is using the WAPM GraphQL API to automatically expose the WASI modules and commands in the online shell
Let's see now a few things that we can do with it!
We can do a POST to https://registry.wapm.io/graphql with the the following as the query
POST field:
{getPackageVersion(name: "python") {versionrepositoryhomepagedistribution {downloadUrlsize}}}
Which should return something similar to:
{"data": {"getPackageVersion": {"version": "0.1.0","repository": "https://github.com/wapm-packages/python","homepage": null,"distribution": {"downloadUrl": "https://registry-cdn.wapm.io/packages/_/python/python-0.1.0.tar.gz","size": 5097541}}}}
If we want to search all the packages published that have certain interface (for example, WASI), we can do a POST to https://registry.wapm.io/graphql with the the following as the query
POST field:
{getInterfaceVersion(name: "wasi", version: "latest") {interface {namedescription}packageVersions {edges {node {versionpackage {name}distribution {downloadUrl}}}}}}
Which should return something similar to:
{"data": {"getInterfaceVersion": {"interface": {"name": "wasi","description": "The WebAssembly System Interface. WASI is a modular system interface for WebAssembly. Itβs focused on security and portability."},"packageVersions": {"edges": [{"node": {"version": "0.1.0","package": {"name": "_/python"},"distribution": {"downloadUrl": "https://registry-cdn.wapm.io/packages/_/python/python-0.1.0.tar.gz"}}},{"node": {"version": "0.0.2","package": {"name": "JeremyLikness/wasi-ubasic"},"distribution": {"downloadUrl": "https://registry-cdn.wapm.io/packages/JeremyLikness/wasi-ubasic/wasi-ubasic-0.0.2.tar.gz"}}},{"node": {"version": "0.4.6","package": {"name": "vshymanskyy/wasm3"},"distribution": {"downloadUrl": "https://registry-cdn.wapm.io/packages/vshymanskyy/wasm3/wasm3-0.4.6.tar.gz"}}}]}}}}
Happy hacking! π