This adds a Koa server and /graphql endpoint to the catalog-server package.
The server is implemented with graphql-helix, which makes it very easy to parse a GraphQL request, execute it against a schema, and send the result. I chose this after koa-graphql seemed unmaintained and have been happy with it.
GraphQL execution is implemented with "resolvers" - objects that let the GraphQL system ask for objects and fields. There are resolvers based on type like PackageInfo, ReadablePackageInfo, PackageVersion, etc. Then field resolvers for sub-collections like ReadablePackageVersion.customElements. The resolvers use the Catalog interface to fetch results. Resolvers are combined with the parsed schema into a "executable schema" which graphql-helix uses to validate and perform the queries.
There is no access control, rate-limiting, etc., yet.
This adds a Koa server and
/graphql
endpoint to thecatalog-server
package.The server is implemented with graphql-helix, which makes it very easy to parse a GraphQL request, execute it against a schema, and send the result. I chose this after koa-graphql seemed unmaintained and have been happy with it.
GraphQL execution is implemented with "resolvers" - objects that let the GraphQL system ask for objects and fields. There are resolvers based on type like
PackageInfo
,ReadablePackageInfo
,PackageVersion
, etc. Then field resolvers for sub-collections likeReadablePackageVersion.customElements
. The resolvers use the Catalog interface to fetch results. Resolvers are combined with the parsed schema into a "executable schema" which graphql-helix uses to validate and perform the queries.There is no access control, rate-limiting, etc., yet.
Fixes #1325