# @ssb-graphql/main

> Main GraphQL types and resolvers for Secure Scuttlebutt

Latest version **11.0.0** (published 2024-04-10) · AGPL-3.0 license · 0 weekly downloads

## Install

```sh
npm install @ssb-graphql/main
pnpm add @ssb-graphql/main
yarn add @ssb-graphql/main
bun add @ssb-graphql/main
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 11.0.0 |
| Published | 2024-04-10 |
| First published | 2020-01-19 |
| Weekly downloads | 0 |
| License | AGPL-3.0 |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 9 |
| Unpacked size | 55.3 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | luandro |
| Maintainers | luandro, mixmix, staltz, chereseeriepa, christianbundy, ben-tai |
| Keywords | scuttlebutt, ahau, graphql |

## Links

- npm: https://www.npmjs.com/package/@ssb-graphql/main
- Repository: https://gitlab.com/ahau/ssb-graphql-main
- Homepage: https://gitlab.com/ahau/ssb-graphql-main#readme
- Issues: https://gitlab.com/ahau/ssb-graphql-main/issues
- npm.io page: https://npm.io/package/@ssb-graphql/main

## Dependencies (9)

- [graphql-tag](https://npm.io/package/graphql-tag.md) ^2.12.6
- [pull-stream](https://npm.io/package/pull-stream.md) ^3.7.0
- [graphql-edtf](https://npm.io/package/graphql-edtf.md) ^2.0.0
- [pull-paramap](https://npm.io/package/pull-paramap.md) ^1.2.2
- [clarify-error](https://npm.io/package/clarify-error.md) ^1.0.0
- [pull-box-stream](https://npm.io/package/pull-box-stream.md) ^1.0.13
- [ssb-hyper-blobs](https://npm.io/package/ssb-hyper-blobs.md) ^4.1.0
- [ssb-serve-blobs](https://npm.io/package/ssb-serve-blobs.md) ^3.3.0
- [stream-to-pull-stream](https://npm.io/package/stream-to-pull-stream.md) ^1.7.3

## Alternatives

- [apollo-link-http-common](https://npm.io/package/apollo-link-http-common.md) — 879.0K weekly downloads
- [react-relay](https://npm.io/package/react-relay.md) — 336.8K weekly downloads
- [relay-test-utils](https://npm.io/package/relay-test-utils.md) — 181.6K weekly downloads
- [@vendure/core](https://npm.io/package/@vendure/core.md) — 14.8K weekly downloads
- [@pnpm/deps.graph-sequencer](https://npm.io/package/@pnpm/deps.graph-sequencer.md) — 13.4K weekly downloads

## Recent versions

- 11.0.0 (latest) — 2024-04-10
- 10.1.1 — 2024-02-19
- 10.1.0 — 2023-07-12
- 10.0.2 — 2023-03-05
- 10.0.1 — 2022-09-06
- 10.0.0 — 2022-07-20
- 9.5.0 — 2022-05-06
- 9.4.5 — 2021-11-28
- 9.4.4 — 2021-10-13
- 9.4.3 — 2021-10-06
- 9.4.2 — 2021-10-05
- 9.4.1 — 2021-09-28
- 9.4.0 — 2021-09-22
- 9.3.0 — 2021-07-18
- 9.2.2 — 2021-07-14
- … 26 more at https://npm.io/package/@ssb-graphql/main/versions

## README

# GraphQL for Secure Scuttlebutt

Main GraphQL types and resolvers for Secure Scuttlebutt.
It provides primitives for CurrentIdentity, file-upload, Date handling etc.

## Usage

`npm i -S @ssb-graphql/main`

## Example Usage

```js
const { ApolloServer } = require('apollo-server-express')
const { buildFederatedSchema } = require('@apollo/federation');

const Server = require('ssb-server')
const Config = require('ssb-config/inject')

const config = Config({})

const ssb = Server
  .use(require('ssb-blobs')) // << required
  .use(require('ssb-serve-blobs')) // << required
  .call(null, config)

const main = require('@ssb-graphql/main')(ssb)

main.loadContext((err, context) => {
  if (err) throw err

  const server = new ApolloServer({
    schema: buildFederatedSchema([
      { typeDefs: main.typeDefs, resolvers: main.resolvers },
      // add other types + resolvers here!
    ]),
    context
  })
})
```

## API

### `require('@ssb-graphql/main')(ssb, opts) => main`

where:
- `ssb` is a scuttlebutt instance
- `opts` *Object* (optional) is of form `{ type: String }` where:
    - `type` is the type of profile created (default: `'person'`)
    

### `main.loadContext(cb)`

Where `cb` is a callback of signature `cb(err, context)` and `context` has form

```js
{
  public: {
    feedId,
    profileId  // requires ssb-profile
  },
  personal: {
    groupId,   // requires ssb-tribes
    profileId  // requires ssb-profile + ssb-tribes
  }
}
```

where:
- the `public` scope are things meant for the public domain,
  - `public.feedId` is the public id of your scuttlebutt instance (this is not a profileId)
  - `public.profileId` points to an unecrypted totally public profile
- the `personal` scope is for things only you will use
  - `personal.groupId` is the id of your personal group (for encrypted notes to self)
  - `personal.profileId` points to a profile for you which encrypted to your personal group (so no-one else will see these details)

NOTE:
- **this will create new records** (profiles / private group) and link them to your feed if they do not already exist
- creating profiles requires `ssb-profile` installed
- creating a personal group with a profile in it further requires `ssb-tribes`
    - if `ssb-tribes` is not installed, this will be skipped
    - if `type` was set to `pataka` when `main` was instantiated, this will also be skipped



## Requirements

An `ssb-server` with the following plugins:
- `ssb-blobs`
- `ssb-serve-blobs`

For `main.loadContext`:
- `ssb-profile`
- `ssb-tribes` (optional, will skip functions if not present)

## Config

Scuttlebutt config that this module listens to:

```js
{
  blobs: {
    max: Number
  },
  serveBlobs: {
    port: Number,
    hostname: String
  },
  hyperBlobs: {
    port: Number
  }
}
```

## API

See `/src/typeDefs.js` for the most up to date details on what's offered by this module.

## TODO

run `npm test` to run tests

---
_Source: https://npm.io/package/@ssb-graphql/main · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
