docs/content/docs/fields/virtual.md
A virtual field represents a value which is computed at read time, rather than stored in the database.
See the virtual fields guide for details on how to use virtual fields.
Options:
field (required): The GraphQL field that defines the type, resolver and arguments.ui.query (default: '' ):
Defines what the Admin UI should fetch from this field, it's interpolated into a query like this:
query {
item(where: { id: "..." }) {
field${ui.query}
}
}
import { config, createSchema, g, list } from '@keystone-6/core';
import { virtual } from '@keystone-6/core/fields';
export default config({
lists: {
SomeListName: list({
fields: {
someFieldName: virtual({
field: g.field({
type: g.String,
args: { something: g.arg({ type: g.Int }) },
resolve(item, args, context, info) {
}
})
}),
/* ... */
},
}),
/* ... */
},
/* ... */
});