> For the complete documentation index, see [llms.txt](https://docs.checkpoint.snapshot.box/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.checkpoint.snapshot.box/guides/one-to-one-relations.md).

# One-to-one relations

It's possible to create one-to-one relations in schema. Those relations will be then available for querying via GraphQL.

### Define relations in schema

To define one-to-one relation nested entity must have `id` field that is either `String!` or `ID!`. In parent entity create field (with any name) that is of nested entity's type (can be nullable or required).

```graphql
type Space {
  id: String!
  name: String
}

type Proposal {
  id: String!
  name: String
  space: Space!
}
```

### Create entities in writer&#x20;

When creating entities in writer set `Proposal`'s `space` field to the value of `Space`'s `id` field.

```typescript
const proposal = new Proposal('proposal_id');
proposal.name = 'Proposal name';
proposal.space = 'Space_id';

await proposal.save();
```

### Query data via GraphQL

It's now possible to nest space entity when querying proposals. You can still filter proposals by space (limited to `Space`'s `id` currently).

```graphql
{
  proposals(first: 10, where: { space: "0x00b60f2a154b9aaec8e4bec8e04f86d6cd92a9c993871e904bd815962603492d" }) {
    id
    space {
      id
      name
    }
  }
}
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.checkpoint.snapshot.box/guides/one-to-one-relations.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
