Skip to content

fix(docs): correct stale @supermemory/memory-graph API references - #1414

Open
thegoodengineer wants to merge 1 commit into
supermemoryai:mainfrom
thegoodengineer:fix/memory-graph-docs-drift
Open

fix(docs): correct stale @supermemory/memory-graph API references#1414
thegoodengineer wants to merge 1 commit into
supermemoryai:mainfrom
thegoodengineer:fix/memory-graph-docs-drift

Conversation

@thegoodengineer

@thegoodengineer thegoodengineer commented Aug 5, 2026

Copy link
Copy Markdown

Summary

apps/docs/integrations/memory-graph.mdx (and, independently, apps/memory-graph-playground/README.md) document an older version of the @supermemory/memory-graph public API. Following the Quick Start, Props Reference, or Exports section as written today produces code that either fails to type-check or silently drops props the component doesn't recognize.

What's wrong (verified against packages/memory-graph/src)

  • Exports section listed Legend, NodeDetailPanel, SpacesDropdown, useGraphInteractions, colors, LAYOUT_CONSTANTS. None of these are exported from packages/memory-graph/src/index.tsx. The real exports are MemoryGraph, GraphCanvas, useGraphData, useGraphTheme, four engine classes, and DEFAULT_COLORS / GRAPH_SETTINGS / etc.
  • Every prop example used loadMoreDocuments, totalLoaded, selectedSpace, onSpaceChange, showSpacesSelector. None of these exist on MemoryGraphProps (packages/memory-graph/src/types.ts). The real props are onLoadMore / totalCount; the space-selector props don't exist on the component at all anymore.
  • documents was typed as DocumentWithMemories[] with a fabricated shape (status, metadata, customId, ...), but MemoryGraphProps.documents is actually GraphApiDocument[] (documentType / memories), a different, incompatible shape. Code copied straight from the docs doesn't compile.
  • The identical drift exists independently in apps/memory-graph-playground/README.md, confirming this isn't a one-off typo but the package's real API having moved on without the docs.

What changed

  • Rewrote Exports to match packages/memory-graph/src/index.tsx exactly, and documented the previously-undocumented ./mock-data subpath export (generateMockGraphData, already used internally by the playground app).
  • Rewrote Quick Start / Backend API Route / the pagination example to use GraphApiDocument[], onLoadMore, totalCount, and added a toGraphDocument mapping function, grounded in apps/web/components/memory-graph/hooks/use-graph-api.ts (the actual production code that calls /v3/documents/documents), showing how to normalize the API's type / memoryEntries fields into the documentType / memories shape the component needs.
  • Removed the Controlled Space Selection example. selectedSpace / onSpaceChange / showSpacesSelector aren't props on the component anymore.
  • Rewrote Props Reference to match MemoryGraphProps field-for-field, including several real props that weren't documented before (containerTags, documentIds, maxNodes, showFps, labels, layering, slideshow props, onOpenDocument).
  • Rewrote Data Types to show the real GraphApiDocument / GraphApiMemory (what documents actually takes) alongside the real DocumentWithMemories / MemoryEntry (the backward-compat exports), instead of a fabricated shape.
  • Fixed Variants: removed the "space selector visible/hidden" claim (no such component exists in the package); kept the 0.8x/0.5x zoom figures, which checked out against constants.ts.
  • Made the Pages Router and Express tabs in Backend API Route fully self-contained (each defines its own toGraphDocument mapping) instead of referencing the App Router tab's helper, since CodeGroup tabs are alternatives a reader copies individually.
  • Applied the identical corrections to apps/memory-graph-playground/README.md.

Not changed

Installation, Performance, and Browser Support sections, and the Variants zoom figures (0.8x / 0.5x). I found no evidence these are inaccurate, so I left them alone to keep the diff scoped to verified errors.

Addressed automated review feedback

Graphite's review left two comments; both are fixed:

  • toGraphDocument (and the Express equivalent) never set GraphApiMemory.content, even though it's a valid field on the type. Added content: mem.content ?? null in all three mapping functions. Worth noting for context: I checked, and this field is provably unused for rendering (packages/memory-graph/src/hooks/use-graph-data.ts always overwrites it with mem.memory before a memory node is drawn), so this wasn't causing the visible "data loss" the comment described, just an unpopulated optional field. Fixed anyway since it's free and makes the mapping match the type exactly.
  • The (data.documents as RawDocument[]) cast was flagged against a custom "avoid type assertions" style rule. Rather than apply the bot's literal suggested diff (which just deletes the cast and leaves data as any, i.e. less type-safe than before), I implemented what its own description asked for: a RawDocumentsResponse interface and a type annotation on data, so data.documents is RawDocument[] without any cast, in both the App Router and Pages Router tabs.

Verification

  • Cross-checked every prop, type, and export against packages/memory-graph/src/{index.tsx,types.ts,api-types.ts,mock-data.ts} and packages/memory-graph/package.json's exports map.
  • Cross-checked the API normalization logic against two independent real call sites: apps/web/components/memory-graph/hooks/use-graph-api.ts and apps/memory-graph-playground/src/app/page.tsx. Both convert the same type / memoryEntries to documentType / memories shape, giving two independent confirmations of the real wire format rather than a guess.
  • Checked the Console/Consumer zoom claim in the Variants section against packages/memory-graph/src/constants.ts (0.8x / 0.5x initial zoom, confirmed accurate) and removed the section's "space selector visible/hidden" claim, which isn't: there's no space-selector component anywhere in packages/memory-graph/src (only six components total, none of them a dropdown/selector).
  • Made every CodeGroup tab in the Backend API Route section standalone (each defines its own toGraphDocument mapping) instead of one tab silently depending on code shown only in another tab.
  • biome.json has no Markdown/MDX support configured in this repo, so bun run format-lint doesn't apply to either changed file (confirmed: bunx biome check explicitly reports both as ignored, 0 files processed). Checked fence and MDX-component balance by hand instead: 34 code-fence lines (17 balanced pairs), and <CodeGroup>/<Note>/<Warning>/<Card> each open/close 1:1.
  • Docs-only change, no .ts/.tsx files touched. apps/docs has no check-types or build script (see apps/docs/package.json), so this change is a structural no-op for those turbo tasks.

@thegoodengineer
thegoodengineer force-pushed the fix/memory-graph-docs-drift branch 2 times, most recently from 9869bf4 to f602a6a Compare August 5, 2026 15:33
Comment on lines +120 to +139
memories: doc.memoryEntries.map((mem): GraphApiMemory => ({
id: mem.id,
memory: mem.memory ?? mem.content ?? '',
isStatic: mem.isStatic ?? false,
spaceId: mem.spaceId ?? '',
isLatest: mem.isLatest ?? true,
isForgotten: mem.isForgotten ?? false,
forgetAfter: mem.forgetAfter ?? null,
forgetReason: mem.forgetReason ?? null,
version: mem.version ?? 1,
parentMemoryId: mem.parentMemoryId ?? null,
rootMemoryId: mem.rootMemoryId ?? null,
createdAt: mem.createdAt,
updatedAt: mem.updatedAt,
relation: mem.relation ?? null,
updatesMemoryId: mem.updatesMemoryId ?? null,
nextVersionId: mem.nextVersionId ?? null,
memoryRelations: mem.memoryRelations ?? null,
spaceContainerTag: mem.spaceContainerTag ?? null,
})),

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The toGraphDocument function drops the content field from RawMemoryEntry when mapping to GraphApiMemory. According to the GraphApiMemory interface defined at lines 389-408, content?: string | null; is a valid optional field, but it's never set in the mapping.

This causes data loss when mem.content exists and is different from mem.memory. The fix is to add the content field to the mapped object:

memories: doc.memoryEntries.map((mem): GraphApiMemory => ({
  id: mem.id,
  memory: mem.memory ?? mem.content ?? '',
  content: mem.content ?? null,  // Add this line
  isStatic: mem.isStatic ?? false,
  // ... rest of fields
}))

Without this, any distinct content in the raw API response will be silently dropped when consumed by components expecting GraphApiDocument[].

Suggested change
memories: doc.memoryEntries.map((mem): GraphApiMemory => ({
id: mem.id,
memory: mem.memory ?? mem.content ?? '',
isStatic: mem.isStatic ?? false,
spaceId: mem.spaceId ?? '',
isLatest: mem.isLatest ?? true,
isForgotten: mem.isForgotten ?? false,
forgetAfter: mem.forgetAfter ?? null,
forgetReason: mem.forgetReason ?? null,
version: mem.version ?? 1,
parentMemoryId: mem.parentMemoryId ?? null,
rootMemoryId: mem.rootMemoryId ?? null,
createdAt: mem.createdAt,
updatedAt: mem.updatedAt,
relation: mem.relation ?? null,
updatesMemoryId: mem.updatesMemoryId ?? null,
nextVersionId: mem.nextVersionId ?? null,
memoryRelations: mem.memoryRelations ?? null,
spaceContainerTag: mem.spaceContainerTag ?? null,
})),
memories: doc.memoryEntries.map((mem): GraphApiMemory => ({
id: mem.id,
memory: mem.memory ?? mem.content ?? '',
content: mem.content ?? null,
isStatic: mem.isStatic ?? false,
spaceId: mem.spaceId ?? '',
isLatest: mem.isLatest ?? true,
isForgotten: mem.isForgotten ?? false,
forgetAfter: mem.forgetAfter ?? null,
forgetReason: mem.forgetReason ?? null,
version: mem.version ?? 1,
parentMemoryId: mem.parentMemoryId ?? null,
rootMemoryId: mem.rootMemoryId ?? null,
createdAt: mem.createdAt,
updatedAt: mem.updatedAt,
relation: mem.relation ?? null,
updatesMemoryId: mem.updatesMemoryId ?? null,
nextVersionId: mem.nextVersionId ?? null,
memoryRelations: mem.memoryRelations ?? null,
spaceContainerTag: mem.spaceContainerTag ?? null,
})),

Spotted by Graphite

Fix in Graphite


Is this helpful? React 👍 or 👎 to let us know.

@thegoodengineer
thegoodengineer force-pushed the fix/memory-graph-docs-drift branch 2 times, most recently from 9209f94 to 2897daa Compare August 5, 2026 15:40
Comment thread apps/docs/integrations/memory-graph.mdx Outdated
Comment on lines +160 to +161
documents: (data.documents as RawDocument[]).map(toGraphDocument),
pagination: data.pagination,

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The code uses a type assertion (as RawDocument[]) on data.documents instead of a type annotation. According to the style guide rule 'Use type annotations instead of assertions for object literals' and 'Avoid unnecessary type assertions', you should avoid as casts where possible. Instead, type data properly (e.g., const data: { documents: RawDocument[]; pagination: unknown } = await response.json();) so that data.documents is already typed as RawDocument[] without needing a cast.

Suggested change
documents: (data.documents as RawDocument[]).map(toGraphDocument),
pagination: data.pagination,
documents: data.documents.map(toGraphDocument),
pagination: data.pagination,

Spotted by Graphite (based on custom rule: TypeScript style guide (Google))

Fix in Graphite


Is this helpful? React 👍 or 👎 to let us know.

apps/docs/integrations/memory-graph.mdx and apps/memory-graph-playground/README.md
documented an older version of the @supermemory/memory-graph public API. Following
the Quick Start, Props Reference, or Exports section as written produced code that
either fails to type-check or silently drops props the component no longer has.

Verified against packages/memory-graph/src/{index.tsx,types.ts,api-types.ts,mock-data.ts,
constants.ts} and cross-checked the API normalization logic against two independent
real call sites: apps/web/components/memory-graph/hooks/use-graph-api.ts and
apps/memory-graph-playground/src/app/page.tsx.

- Exports section listed Legend, NodeDetailPanel, SpacesDropdown, useGraphInteractions,
  colors, LAYOUT_CONSTANTS - none of these are actually exported. Corrected to the
  real exports and added the previously-undocumented ./mock-data subpath.
- All examples used loadMoreDocuments/totalLoaded/selectedSpace/onSpaceChange/
  showSpacesSelector, none of which exist on MemoryGraphProps. Corrected to
  onLoadMore/totalCount and removed the Controlled Space Selection example
  (that feature no longer exists on the component).
- documents was typed as DocumentWithMemories[] with a fabricated shape; the real
  prop type is GraphApiDocument[]. Added a toGraphDocument mapping example grounded
  in the real production code that talks to /v3/documents/documents.
- Rewrote Props Reference and Data Types to match the real MemoryGraphProps and
  GraphApiDocument/GraphApiMemory interfaces field-for-field, including several
  real props that weren't documented at all before.
- Removed the false 'space selector visible/hidden' claim from the Variants section
  (no such component exists anywhere in packages/memory-graph/src); kept the 0.8x/0.5x
  zoom figures, which checked out against constants.ts.
- Made the Pages Router and Express tabs in Backend API Route self-contained (each
  defines its own toGraphDocument mapping) instead of depending on code shown only
  in the App Router tab, since CodeGroup tabs are alternatives a reader copies
  individually.
- Applied the identical corrections to apps/memory-graph-playground/README.md,
  which had the same drift independently.

Address Graphite automated review feedback:
- Set the content field in all three toGraphDocument mappings (was a valid but
  unpopulated field on GraphApiMemory). Confirmed via use-graph-data.ts that it's
  inert for rendering (always overwritten with mem.memory before draw), so this
  wasn't visible data loss, but it's a free fix that matches the type exactly.
- Replaced the (data.documents as RawDocument[]) cast with a proper
  RawDocumentsResponse type annotation on data in the App Router and Pages Router
  tabs, per the custom TypeScript style rule Graphite flagged. Implemented what
  the comment's prose described rather than its literal suggested diff, which
  would have just deleted the cast and left data as any.

Docs-only change, no .ts/.tsx files touched. This repo's biome.json has no
Markdown/MDX support configured, so format-lint doesn't apply here; checked
fence and MDX-component balance by hand instead (34 fence lines, all CodeGroup/
Note/Warning/Card tags balanced 1:1).
@thegoodengineer
thegoodengineer force-pushed the fix/memory-graph-docs-drift branch from 2897daa to 8d3f7ac Compare August 5, 2026 15:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant