> ## Documentation Index
> Fetch the complete documentation index at: https://docs.metabind.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Resolved Package

> Package data with resolved dependencies

Package resolution types are used to retrieve all component and asset data needed to render content. Choose between full resolution (simpler) or reference resolution (efficient caching).

## ResolvedPackage

Full package data with all resolved dependencies inline.

```graphql theme={null}
type ResolvedPackage {
  package: ResolvedPackageData!
  dependencies: [ResolvedPackageData!]!
}
```

| Field          | Type                     | Description                 |
| -------------- | ------------------------ | --------------------------- |
| `package`      | ResolvedPackageData!     | Main package data           |
| `dependencies` | \[ResolvedPackageData!]! | All dependency package data |

Use when you want all data in a single request:

```graphql theme={null}
query GetContentResolved($id: ID!) {
  content(id: $id) {
    compiled
    resolvedPackage {
      package {
        version
        components
        assets
      }
      dependencies {
        version
        components
        assets
      }
    }
  }
}
```

## ResolvedPackageRef

Package IDs only, for normalized caching.

```graphql theme={null}
type ResolvedPackageRef {
  package: ID!
  cdnUrl: String
  dependencies: [ID!]!
}
```

| Field          | Type    | Description                                                             |
| -------------- | ------- | ----------------------------------------------------------------------- |
| `package`      | ID!     | Main package ID (content-addressed hash or `draft:{projectId}:{orgId}`) |
| `cdnUrl`       | String  | CDN URL for fetching package data                                       |
| `dependencies` | \[ID!]! | Dependency package IDs (hashes or draft IDs)                            |

Use for efficient caching (smaller payloads):

```graphql theme={null}
query GetContentWithCaching($id: ID!) {
  content(id: $id) {
    compiled
    resolvedRef {
      package
      dependencies
    }
  }
}
```

Response:

```json theme={null}
{
  "data": {
    "content": {
      "compiled": "const body = () => { ... }",
      "resolvedRef": {
        "package": "abc123def456...",
        "dependencies": ["xyz789ghi012..."]
      }
    }
  }
}
```

Then fetch package data separately using [resolvedPackageData](/graphql/queries/package-data).

## ResolvedPackageData

Package data identified by content-addressed hash.

```graphql theme={null}
type ResolvedPackageData {
  id: ID!
  version: String!
  components: String!
  assets: String!
  cdnUrl: String
}
```

| Field        | Type    | Description                                             |
| ------------ | ------- | ------------------------------------------------------- |
| `id`         | ID!     | SHA-256 hash, or `draft:{projectId}:{orgId}` for drafts |
| `version`    | String! | Semantic version                                        |
| `components` | String! | JSON object mapping component names to compiled code    |
| `assets`     | String! | JSON object mapping component names to asset arrays     |
| `cdnUrl`     | String  | CDN URL for fetching package data                       |

### Components Field

JSON object with component name as key and compiled code as value:

```json theme={null}
{
  "ProductCard": "const body = (props) => { return VStack([...]) }",
  "ArticleLayout": "const body = (props) => { return ScrollView([...]) }"
}
```

### Assets Field

JSON object with component name as key and asset array as value:

```json theme={null}
{
  "ProductCard": [
    { "name": "placeholder", "url": "https://cdn.metabind.ai/..." }
  ],
  "ArticleLayout": []
}
```

## Draft Package IDs

Draft packages use a special ID format instead of a content hash:

```
draft:{projectId}:{organizationId}
```

Example: `draft:proj123:org456`

<Warning>
  Draft packages should not be cached long-term as they change frequently during development.
</Warning>

```javascript theme={null}
function isDraftPackage(id) {
  return id.startsWith('draft:');
}

// Only cache published packages
if (!isDraftPackage(packageId)) {
  cache.set(packageId, data);
}
```

## Caching Strategy

Content-addressed IDs (SHA-256 hashes) mean published packages never change:

```javascript theme={null}
const packageCache = new Map();

async function getPackageData(id) {
  // Draft packages: always fetch fresh
  if (id.startsWith('draft:')) {
    return await fetchPackageData(id);
  }

  // Published packages: cache forever
  if (packageCache.has(id)) {
    return packageCache.get(id);
  }

  const data = await fetchPackageData(id);
  packageCache.set(id, data);
  return data;
}
```

## Related Types

* [Package](/graphql/types/package) - Package type with resolution fields
* [Content](/graphql/types/content) - Content with resolved packages
