Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/ws2 3149 put all the docs to docusaurus repo from notion #222

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion website/docs/api/runtime/schema.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -686,7 +686,7 @@ type Mutation {

### Document update

Similart to document creation, document update uses two input objects for the content fields and another one wrapping it, as well as an options object.
Similar to document creation, document update uses two input objects for the content fields and another one wrapping it, as well as an options object.

For example, using the following [Schema definition](https://developers.ceramic.network/docs/composedb/guides/data-modeling/schemas):

Expand Down
39 changes: 35 additions & 4 deletions website/docs/api/sdl/directives.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,15 @@ When using the `@createModel` directive, two parameters must be provided:

- `accountRelation`: the type of relation between documents created using the
Model and the account controlling the document, which can be `SINGLE` for a
single document of the given Model (for example profile information), or
`LIST` (default) for a potentially infinite list of documents. When creating
interfaces, the `accountRelation` is ignored if provided.
single document of the given Model (for example profile information), `SET`
for multiple deterministic documents based on one or more content fields, or
`LIST` (default) for a potentially infinite list of documents.
- `description`: a string describing the Model, to help with discovery.
- `accountRelationFields`: a list of content field names defining the `SET` account
relation. This argument is required when the `accountRelation` is `SET`. When creating interfaces, the `accountRelation` is ignored if provided.

Example:
Example for a `LIST` account relation:
This allows a user to create any number of posts.

```graphql
type Post @createModel(accountRelation: LIST, description: "A simple text post") {
Expand All @@ -29,6 +32,28 @@ type Post @createModel(accountRelation: LIST, description: "A simple text post")
}
```

Examples for `SINGLE` and `SET` account relations:
This allows a user to create a single picture per did, as well as to set an individual picture as favorite, they can have different pictures set as favorite, but only one `favorite` record for a did per picture.

```graphql
type Picture @createModel(description: "A model for pictures", accountRelation: SINGLE) {
src: String! @string(maxLength: 150)
mimeType: String! @string(maxLength: 50)
width: Int! @int(min: 1)
height: Int! @int(min: 1)
size: Int @int(min: 1)
}

type Favorite @createModel(description: "A set of favorite documents", accountRelation: SET, accountRelationFields: ["docID"]) {
docID: StreamID! @documentReference(model: "Picture")
doc: Node @relationDocument(property: "docID")
note: String @string(maxLength: 500)
}
```
:::caution
Notice that when the account relation of a model is `SET` it is required to include `accountRelationFields` to specify which field is being used to create the set.
:::

### `@loadModel`

The `@loadModel` directive can be used to identify pre-existing models and use
Expand Down Expand Up @@ -197,6 +222,12 @@ the [`CommitID` scalar type](./scalars.mdx#commitid).

Example: `version: CommitID! @documentVersion`.

### `@immutable`
JulissaDantes marked this conversation as resolved.
Show resolved Hide resolved

Defines a field value as unchangeable, like a read-only value, and any efforts to edit it will result in an error prompt.

Example: `createdAt: DateTime! @immutable`

## Relation views

### `@relationDocument`
Expand Down
Loading