To fetch or load references or Symbols, you must use enrich in your calls to fetch multiple entries from Builder.
Pass in the options object with enrich: true when using getAll() in a Gen 1 SDK and fetchEntries() in a Gen 2 SDK. This provides a consistent experience between the Visual Editor and the live site.
Tip: The enrich attribute returns the fetched reference and three additional layers of depth for nested references. If you access a reference or Symbol with more than 3 layers of nested references, later layers will not be enriched.
Tip: Builder enriches by default for Gen 1's builder.get() and Gen 2's fetchOneEntry().
To fetch or load references or Symbols, be sure to manually pass in enrich: true when using getAll().
import { builder } from '@builder.io/react';
const pages = await builder.getAll('page', {
// to fetch references and Symbols
options: { enrich: true }
});To fetch or load references or Symbols, be sure to manually pass in enrich: true when using fetchEntries().
import { fetchEntries } from '@builder.io/sdk-react';
const pages = await fetchEntries({
model: 'page',
apiKey: 'YOUR_API_KEY',
// to fetch references and Symbols
options: { enrich: true }
});
To fetch or load references or Symbols, be sure to manually pass in enrich: true when using getAll().
import { builder } from '@builder.io/react';
const pages = await builder.getAll('page', {
// to fetch references and Symbols
options: { enrich: true }
});To fetch or load references or Symbols, be sure to manually pass in enrich: true when using fetchEntries().
import { fetchEntries } from '@builder.io/sdk-react';
const pages = await fetchEntries({
model: 'page',
apiKey: 'YOUR_API_KEY',
// to fetch references and Symbols
options: { enrich: true }
});
To fetch or load references or Symbols, be sure to manually pass in enrich: true when using getAll().
import { builder } from '@builder.io/react';
const pages = await builder.getAll('page', {
// to fetch references and Symbols
options: { enrich: true }
});To fetch or load references or Symbols, be sure to manually pass in enrich: true when using fetchEntries().
import { fetchEntries } from '@builder.io/sdk-react';
const pages = await fetchEntries({
model: 'page',
apiKey: 'YOUR_API_KEY',
// to fetch references and Symbols
options: { enrich: true }
});
To fetch or load references or Symbols, be sure to manually pass in enrich: true when using fetchEntries().
import { fetchEntries } from '@builder.io/sdk-react';
const pages = await fetchEntries({
model: 'page',
apiKey: 'YOUR_API_KEY',
// to fetch references and Symbols
options: { enrich: true }
});
To fetch or load references or Symbols, be sure to manually pass in enrich: true when using getAll().
import { builder } from '@builder.io/react';
const pages = await builder.getAll('page', {
// to fetch references and Symbols
options: { enrich: true }
});To fetch or load references or Symbols, be sure to manually pass in enrich: true when using fetchEntries().
import { fetchEntries } from '@builder.io/sdk-react';
const pages = await fetchEntries({
model: 'page',
apiKey: 'YOUR_API_KEY',
// to fetch references and Symbols
options: { enrich: true }
});
To fetch or load references or Symbols, be sure to manually pass in enrich: true when using getAll().
import { builder } from '@builder.io/react';
const pages = await builder.getAll('page', {
// to fetch references and Symbols
options: { enrich: true }
});To fetch or load references or Symbols, be sure to manually pass in enrich: true when using fetchEntries().
import { fetchEntries } from '@builder.io/sdk-react';
const pages = await fetchEntries({
model: 'page',
apiKey: 'YOUR_API_KEY',
// to fetch references and Symbols
options: { enrich: true }
});
To fetch or load references or Symbols, be sure to manually pass in enrich: true when using fetchEntries().
import { fetchEntries } from '@builder.io/sdk-react';
const pages = await fetchEntries({
model: 'page',
apiKey: 'YOUR_API_KEY',
// to fetch references and Symbols
options: { enrich: true }
});
To fetch or load references or Symbols, be sure to manually pass in enrich: true when using fetchEntries().
import { fetchEntries } from '@builder.io/sdk-react';
const pages = await fetchEntries({
model: 'page',
apiKey: 'YOUR_API_KEY',
// to fetch references and Symbols
options: { enrich: true }
});
To fetch or load references or Symbols, be sure to manually pass in enrich: true when using fetchEntries().
import { fetchEntries } from '@builder.io/sdk-react';
const pages = await fetchEntries({
model: 'page',
apiKey: 'YOUR_API_KEY',
// to fetch references and Symbols
options: { enrich: true }
});
To fetch or load references or Symbols, be sure to manually pass in enrich: true when using fetchEntries().
import { fetchEntries } from '@builder.io/sdk-react';
const pages = await fetchEntries({
model: 'page',
apiKey: 'YOUR_API_KEY',
// to fetch references and Symbols
options: { enrich: true }
});
To fetch or load references or Symbols, be sure to manually pass in enrich: true when using fetchEntries().
import { fetchEntries } from '@builder.io/sdk-react';
const pages = await fetchEntries({
model: 'page',
apiKey: 'YOUR_API_KEY',
// to fetch references and Symbols
options: { enrich: true }
});
To fetch or load references or Symbols, be sure to manually pass in enrich: true when using fetchEntries().
import { fetchEntries } from '@builder.io/sdk-react';
const pages = await fetchEntries({
model: 'page',
apiKey: 'YOUR_API_KEY',
// to fetch references and Symbols
options: { enrich: true }
});
To fetch or load references or Symbols, be sure to manually pass in enrich: true when using getAll().
import { builder } from '@builder.io/react';
const pages = await builder.getAll('page', {
// to fetch references and Symbols
options: { enrich: true }
});To fetch or load references or Symbols, be sure to manually pass in enrich: true when using fetchEntries().
import { fetchEntries } from '@builder.io/sdk-react';
const pages = await fetchEntries({
model: 'page',
apiKey: 'YOUR_API_KEY',
// to fetch references and Symbols
options: { enrich: true }
});
To fetch or load references or Symbols, be sure to manually pass in enrich: true when using getAll().
import { builder } from '@builder.io/react';
const pages = await builder.getAll('page', {
// to fetch references and Symbols
options: { enrich: true }
});When enriching data from the Content API, you may wish to exclude some fields or include only specific fields. When enrich is set to true, use the enrichOptions key to define precisely what information to receive.
enrichOptions accepts an object with two possible values:
- model: This key expects an object where each key is the name of a Model and each value is an object. Each object should include either the
fieldskey, representing which fields to include, theomitkey, representing which fields to exclude, or both keys. - enrichLevel: This key accepts a value greater than 0 and determines the depth level for enriching. For example, an
enrichLevelof 1 would return one additional nested model within the original response. The max level is 4.
import { builder } from "@builder.io/react";
const entry = await builder.get('post', {
...
options: {
enrich: true,
enrichOptions: {
model: {
author: {
fields: "id,name,data",
omit: "data.blocks",
},
category: {
fields: "id,name",
},
},
enrichLevel: 2,
},
},
...
})The example above demonstrates a request to a post model with two nested models: author and category. For author, the name, id, and data values are included in the response, except the data.blocks value is exclude.
For the category model, only id and name are included in the response. Finally, with enrichLevel set to 2, two additional levels of depth will be included within the response, nested within the post model.
import { fetchOneEntry } from "@builder.io/sdk-react";
const entry = await fetchOneEntry({
...
options: {
enrich: true,
enrichOptions: {
model: {
author: {
fields: "id,name,data",
omit: "data.blocks",
},
category: {
fields: "id,name",
},
},
enrichLevel: 2,
},
},
...
});The example above demonstrates a request to a post model with two nested models: author and category. For author, the name, id, and data values are included in the response, except the data.blocks value is excluded.
For the category model, only id and name are included in the response. Finally, with enrichLevel set to 2, two additional levels of depth will be included within the response, nested within the post model.
import { builder } from "@builder.io/react";
const entry = await builder.get('post', {
...
options: {
enrich: true,
enrichOptions: {
model: {
author: {
fields: "id,name,data",
omit: "data.blocks",
},
category: {
fields: "id,name",
},
},
enrichLevel: 2,
},
},
...
})The example above demonstrates a request to a post model with two nested models: author and category. For author, the name, id, and data values are included in the response, except the data.blocks value is exclude.
For the category model, only id and name are included in the response. Finally, with enrichLevel set to 2, two additional levels of depth will be included within the response, nested within the post model.
import { fetchOneEntry } from "@builder.io/sdk-react";
const entry = await fetchOneEntry({
...
options: {
enrich: true,
enrichOptions: {
model: {
author: {
fields: "id,name,data",
omit: "data.blocks",
},
category: {
fields: "id,name",
},
},
enrichLevel: 2,
},
},
...
});The example above demonstrates a request to a post model with two nested models: author and category. For author, the name, id, and data values are included in the response, except the data.blocks value is exclude.
For the category model, only id and name are included in the response. Finally, with enrichLevel set to 2, two additional levels of depth will be included within the response, nested within the post model.
import { builder } from "@builder.io/react";
const entry = await builder.get('post', {
...
options: {
enrich: true,
enrichOptions: {
model: {
author: {
fields: "id,name,data",
omit: "data.blocks",
},
category: {
fields: "id,name",
},
},
enrichLevel: 2,
},
},
...
})The example above demonstrates a request to a post model with two nested models: author and category. For author, the name, id, and data values are included in the response, except the data.blocks value is exclude.
For the category model, only id and name are included in the response. Finally, with enrichLevel set to 2, two additional levels of depth will be included within the response, nested within the post model.
import { fetchOneEntry } from "@builder.io/sdk-react";
const entry = await fetchOneEntry({
...
options: {
enrich: true,
enrichOptions: {
model: {
author: {
fields: "id,name,data",
omit: "data.blocks",
},
category: {
fields: "id,name",
},
},
enrichLevel: 2,
},
},
...
});The example above demonstrates a request to a post model with two nested models: author and category. For author, the name, id, and data values are included in the response, except the data.blocks value is exclude.
For the category model, only id and name are included in the response. Finally, with enrichLevel set to 2, two additional levels of depth will be included within the response, nested within the post model.
import { fetchOneEntry } from "@builder.io/sdk-react";
const entry = await fetchOneEntry({
...
options: {
enrich: true,
enrichOptions: {
model: {
author: {
fields: "id,name,data",
omit: "data.blocks",
},
category: {
fields: "id,name",
},
},
enrichLevel: 2,
},
},
...
});The example above demonstrates a request to a post model with two nested models: author and category. For author, the name, id, and data values are included in the response, except the data.blocks value is exclude.
For the category model, only id and name are included in the response. Finally, with enrichLevel set to 2, two additional levels of depth will be included within the response, nested within the post model.
import { builder } from "@builder.io/react";
const entry = await builder.get('post', {
...
options: {
enrich: true,
enrichOptions: {
model: {
author: {
fields: "id,name,data",
omit: "data.blocks",
},
category: {
fields: "id,name",
},
},
enrichLevel: 2,
},
},
...
})The example above demonstrates a request to a post model with two nested models: author and category. For author, the name, id, and data values are included in the response, except the data.blocks value is exclude.
For the category model, only id and name are included in the response. Finally, with enrichLevel set to 2, two additional levels of depth will be included within the response, nested within the post model.
import { fetchOneEntry } from "@builder.io/sdk-react";
const entry = await fetchOneEntry({
...
options: {
enrich: true,
enrichOptions: {
model: {
author: {
fields: "id,name,data",
omit: "data.blocks",
},
category: {
fields: "id,name",
},
},
enrichLevel: 2,
},
},
...
});The example above demonstrates a request to a post model with two nested models: author and category. For author, the name, id, and data values are included in the response, except the data.blocks value is exclude.
For the category model, only id and name are included in the response. Finally, with enrichLevel set to 2, two additional levels of depth will be included within the response, nested within the post model.
import { builder } from "@builder.io/react";
const entry = await builder.get('post', {
...
options: {
enrich: true,
enrichOptions: {
model: {
author: {
fields: "id,name,data",
omit: "data.blocks",
},
category: {
fields: "id,name",
},
},
enrichLevel: 2,
},
},
...
})The example above demonstrates a request to a post model with two nested models: author and category. For author, the name, id, and data values are included in the response, except the data.blocks value is exclude.
For the category model, only id and name are included in the response. Finally, with enrichLevel set to 2, two additional levels of depth will be included within the response, nested within the post model.
import { fetchOneEntry } from "@builder.io/sdk-svelte";
const entry = await fetchOneEntry({
...
options: {
enrich: true,
enrichOptions: {
model: {
author: {
fields: "id,name,data",
omit: "data.blocks",
},
category: {
fields: "id,name",
},
},
enrichLevel: 2,
},
},
...
});The example above demonstrates a request to a post model with two nested models: author and category. For author, the name, id, and data values are included in the response, except the data.blocks value is exclude.
For the category model, only id and name are included in the response. Finally, with enrichLevel set to 2, two additional levels of depth will be included within the response, nested within the post model.
import { fetchOneEntry } from "@builder.io/sdk-vue";
const entry = await fetchOneEntry({
...
options: {
enrich: true,
enrichOptions: {
model: {
author: {
fields: "id,name,data",
omit: "data.blocks",
},
category: {
fields: "id,name",
},
},
enrichLevel: 2,
},
},
...
});The example above demonstrates a request to a post model with two nested models: author and category. For author, the name, id, and data values are included in the response, except the data.blocks value is exclude.
For the category model, only id and name are included in the response. Finally, with enrichLevel set to 2, two additional levels of depth will be included within the response, nested within the post model.
import { fetchOneEntry } from "@builder.io/sdk-vue";
const entry = await fetchOneEntry({
...
options: {
enrich: true,
enrichOptions: {
model: {
author: {
fields: "id,name,data",
omit: "data.blocks",
},
category: {
fields: "id,name",
},
},
enrichLevel: 2,
},
},
...
});The example above demonstrates a request to a post model with two nested models: author and category. For author, the name, id, and data values are included in the response, except the data.blocks value is exclude.
For the category model, only id and name are included in the response. Finally, with enrichLevel set to 2, two additional levels of depth will be included within the response, nested within the post model.
import { fetchOneEntry } from "@builder.io/sdk-qwik";
const entry = await fetchOneEntry({
...
options: {
enrich: true,
enrichOptions: {
model: {
author: {
fields: "id,name,data",
omit: "data.blocks",
},
category: {
fields: "id,name",
},
},
enrichLevel: 2,
},
},
...
});The example above demonstrates a request to a post model with two nested models: author and category. For author, the name, id, and data values are included in the response, except the data.blocks value is exclude.
For the category model, only id and name are included in the response. Finally, with enrichLevel set to 2, two additional levels of depth will be included within the response, nested within the post model.
import { fetchOneEntry } from "@builder.io/sdk-react";
const entry = await fetchOneEntry({
...
options: {
enrich: true,
enrichOptions: {
model: {
author: {
fields: "id,name,data",
omit: "data.blocks",
},
category: {
fields: "id,name",
},
},
enrichLevel: 2,
},
},
...
});The example above demonstrates a request to a post model with two nested models: author and category. For author, the name, id, and data values are included in the response, except the data.blocks value is exclude.
For the category model, only id and name are included in the response. Finally, with enrichLevel set to 2, two additional levels of depth will be included within the response, nested within the post model.
export class myComponent {
content: BuilderContent | null = null;
async ngOnInit() {
const content = await fetchOneEntry({
//define enrich inside options object
options: { enrich: true },
enrichOptions: {
model: {
author: {
fields: "id,name,data",
omit: "data.blocks",
},
category: {
fields: "id,name",
},
},
enrichLevel: 2,
}
});
this.content = content;
}
}The example above demonstrates a request to a post model with two nested models: author and category. For author, the name, id, and data values are included in the response, except the data.blocks value is exclude.
For the category model, only id and name are included in the response. Finally, with enrichLevel set to 2, two additional levels of depth will be included within the response, nested within the post model.
export const myComponentResolver: any => {
...
return fetchOneEntry({
options: { enrich: true },
enrichOptions: {
model: {
author: {
fields: "id,name,data",
omit: "data.blocks",
},
category: {
fields: "id,name",
},
},
enrichLevel: 2,
}
});
};The example above demonstrates a request to a post model with two nested models: author and category. For author, the name, id, and data values are included in the response, except the data.blocks value is exclude.
For the category model, only id and name are included in the response. Finally, with enrichLevel set to 2, two additional levels of depth will be included within the response, nested within the post model.
import { builder } from "@builder.io/react";
const entry = await builder.get('post', {
...
options: {
enrich: true,
enrichOptions: {
model: {
author: {
fields: "id,name,data",
omit: "data.blocks",
},
category: {
fields: "id,name",
},
},
enrichLevel: 2,
},
},
...
})The example above demonstrates a request to a post model with two nested models: author and category. For author, the name, id, and data values are included in the response, except the data.blocks value is exclude.
For the category model, only id and name are included in the response. Finally, with enrichLevel set to 2, two additional levels of depth will be included within the response, nested within the post model.
import { fetchOneEntry } from "@builder.io/sdk-react";
const entry = await fetchOneEntry({
...
options: {
enrich: true,
enrichOptions: {
model: {
author: {
fields: "id,name,data",
omit: "data.blocks",
},
category: {
fields: "id,name",
},
},
enrichLevel: 2,
},
},
...
});The example above demonstrates a request to a post model with two nested models: author and category. For author, the name, id, and data values are included in the response, except the data.blocks value is exclude.
For the category model, only id and name are included in the response. Finally, with enrichLevel set to 2, two additional levels of depth will be included within the response, nested within the post model.
&enrich=true&enrichOptions.model.navigation.fields=id,name,data&enrichOptions.model.navigation.omit=data.titleThe example above demonstrates a request to a navigation model. The id, name, and data fields are included in the response. However, from the data field, the data.title is omitted.
import { BuilderModule } from "@builder.io/angular";
const entry = await builder.get('post', {
...
options: {
enrich: true,
enrichOptions: {
model: {
author: {
fields: "id,name,data",
omit: "data.blocks",
},
category: {
fields: "id,name",
},
},
enrichLevel: 2,
},
},
...
})The example above demonstrates a request to a post model with two nested models: author and category. For author, the name, id, and data values are included in the response, except the data.blocks value is exclude.
For the category model, only id and name are included in the response. Finally, with enrichLevel set to 2, two additional levels of depth will be included within the response, nested within the post model.
import { builder } from "@builder.io/sdk";
const entry = await builder.get('post', {
...
options: {
enrich: true,
enrichOptions: {
model: {
author: {
fields: "id,name,data",
omit: "data.blocks",
},
category: {
fields: "id,name",
},
},
enrichLevel: 2,
},
},
...
})The example above demonstrates a request to a post model with two nested models: author and category. For author, the name, id, and data values are included in the response, except the data.blocks value is exclude.
For the category model, only id and name are included in the response. Finally, with enrichLevel set to 2, two additional levels of depth will be included within the response, nested within the post model.
For more detail on the Gen 2 (or Mitosis) SDKs, see the Builder GitHub repo.