powerhouse-inc / switchboard

Open-source API over the document model made to be developer- and analyst-friendly
https://switchboard-boilerplate.vercel.app
GNU Affero General Public License v3.0
3 stars 3 forks source link

Make API extensible via npm packages #67

Closed KirillDogadin-std closed 12 months ago

KirillDogadin-std commented 1 year ago

Closes https://github.com/powerhouse-inc/switchboard-boilerplate/issues/61

Screenshot 2023-11-08 at 11 21 54
KirillDogadin-std commented 1 year ago

@valiafetisov time for opinion

If the module is conform with nexus structure, then it's quite easy to just define it and import to the schema. In more sofishticated cases when we e.g. need to define crud operations in models.ts. See the tricks that i've used to make it work together.

Disclaimer: the example directories with "modules" contain package.jsons from the api that is barely different. So CI fails and the installations there do not make sense. I.e. the code here is just to showcase how things would be modularized but not a reviewable code.

KirillDogadin-std commented 1 year ago

did the independent counter example, the gql query for it:

query {
  countUsers(message: "aslekjf") { count, message}
}
KirillDogadin-std commented 1 year ago

Currently trying to find a way of writing the module so that the type system remains intact. To discuss this issue i would assume that code demo should be available, hence will open a separate draft PR that is not for merging but for demo purposes only. #68

valiafetisov commented 12 months ago

I've added a readme section on how to make new modules: https://github.com/powerhouse-inc/switchboard-boilerplate/blob/b863e6a2b778fe572298123caa981cc1d33b8ecf/api/README.md#adding-new-modules