Figured it out. In case anyone else is stuck with this problem, I resolved it in with the following code.
const Bookmark = objectType({}) // same as above
const BookmarkList = objectType({
name: 'BookmarkList',
definition(t) {
t.field('bookmarks', {
type: nonNull(list('Bookmark'))
})
}
})
const BookmarkResult = unionType({
type: 'BookmarkResult',
definition(t) {
t.members('BookmarkList', 'NotAllowedError', 'NotFoundError', 'UnknownError')
}
})
const BookmarkQuery = queryField({}) // same as above
Answer from Joshua Richardson on Stack OverflowNexus Schema
nexusjs.org › docs › api › query-field
queryField
Often times you want to split up query fields into different domains of your application, and like mutationField are another one of the most common use-cases for extendType. queryField exists as a shorthand for this common case:
Nexus Schema
nexusjs.org › docs
Nexus Documentation (Concepts, Reference & Guides)
Why Nexus? Examples · Guides · Schema · Nullability · Source Types · Abstract Types · Library Authors · Best Practices · Generated Artifacts · API · Introduction · objectType · subscriptionType · unionType · scalarType · interfaceType · enumType · inputObjectType · args · list / nonNull · makeSchema · extendType · mutationField · queryField ·
GitHub
github.com › prisma › nexus › issues › 201
queryField for list · Issue #201 · graphql-nexus/nexus
August 19, 2019 - What is de equivalent with queryField for this list query ? const Query = objectType({ name: "Query", definition(t) { t.list.field("posts", { .... I cannot find anything in the docs or examples.... Thank you!
Author graphql-nexus
Hotexamples
typescript.hotexamples.com › examples › nexus › - › queryField › typescript-queryfield-function-examples.html
TypeScript queryField Examples, nexus.queryField TypeScript Examples - HotExamples
t.id('id'); t.dateTime('createdAt'); t.dateTime('updatedAt'); t.string('email'); t.string('themeName'); t.list.field('webs', { type: 'Web', resolve: (root, _args, context) => context.models.user.webs(root.id), }); }, }); // https://medium.com/workflowgen/graphql-schema-design-the-viewer-field-aeabfacffe72 export const viewer = queryField('viewer', { type: User, nullable: true, resolve: (_root, _args, context) => context.models.user.viewer(), }); // requiredViewer throws, so the app can redirect. export const requiredViewer = queryField('requiredViewer', { type: User, resolve: (_root, _args, co
GitHub
github.com › graphql-nexus › nexus-result-field
GitHub - graphql-nexus/nexus-result-field
October 18, 2021 - nexus-result-field makes it easy to encode query and mutation operation errors in your schema with Nexus.
Starred by 15 users
Forked by 2 users
Languages TypeScript 99.3% | JavaScript 0.7% | TypeScript 99.3% | JavaScript 0.7%
npm
npmjs.com › package › nexus-result-field
nexus-result-field - npm
October 18, 2021 - nexus-result-field makes it easy to encode query and mutation operation errors in your schema with Nexus.
» npm install nexus-result-field
Published Oct 18, 2021
Version 0.2.1
Author Jason Kuhrt
GitHub
github.com › graphql-nexus › nexus-plugin-prisma › issues › 972
New way to define nullable and list in queryField or mutationField? · Issue #972 · graphql-nexus/nexus-plugin-prisma
November 25, 2020 - export const notifications = queryField('notifications', { type: 'Notification', nullable: false, list: true, args: { userId: stringArg(), }, resolve: (parent, { userId }, ctx) => { return ctx.prisma.notification.findMany({ where: { userId, }, }); }, });
Author graphql-nexus
npm
npmjs.com › package › nexus-pagination-plugin
nexus-pagination-plugin - npm
// User Type export const User = objectType({ name: 'User', description: 'A User', definition(t) { t.nonNull.id('id'); t.nonNull.string('firstName'); t.nonNull.string('lastName'); }, }); // add paginated users query export const UsersQuery = queryField((t) => { t.paginatedQueryResult('users', { type: 'User', resolve: async (_root, args, ctx) => { const { take, skip } = ctx.paginationParams; const users = await ctx.prisma.user.findMany({ skip, take, }); const usersCount = await ctx.prisma.user.count(); const pageInfo = ctx.calculatePageInfo(usersCount); return { results: users, pageInfo } }, }) })
» npm install nexus-pagination-plugin
Published Apr 07, 2022
Version 0.1.6
Author Echobind
GitHub
github.com › graphql-nexus › nexus-result-field › blob › main › README.md
nexus-result-field/README.md at main · graphql-nexus/nexus-result-field
nexus-result-field makes it easy to encode query and mutation operation errors in your schema with Nexus.
Author graphql-nexus
Nexus Schema
nexusjs.org › docs › guides › schema
Schema
Why Nexus? Examples · Guides · Schema · Nullability · Source Types · Abstract Types · Library Authors · Best Practices · Generated Artifacts · API · Introduction · objectType · subscriptionType · unionType · scalarType · interfaceType · enumType · inputObjectType · args · list / nonNull · makeSchema · extendType · mutationField · queryField ·
Nexus Schema
nexusjs.org › docs › api › args
args
Why Nexus? Examples · Guides · Schema · Nullability · Source Types · Abstract Types · Library Authors · Best Practices · Generated Artifacts · API · Introduction · objectType · subscriptionType · unionType · scalarType · interfaceType · enumType · inputObjectType · args · list / nonNull · makeSchema · extendType · mutationField · queryField ...
Nexus Schema
nexusjs.org › docs › plugins › field-authorize
Field Authorize
The field Authorize Plugin plugin provides a new property on the field config called authorize · It allows us to define field-level authorization to a query:
Skypack
skypack.dev › view › nexus-validate-plugin
npm:nexus-validate-plugin | Skypack
February 12, 2021 - import { intArg, stringArg, booleanArg, floatArg, idArg, arg, } from 'nexus-validate-plugin' import { objectType, queryField } from '@nexus/schema' import { intArg, stringArg } from 'nexus-validate-plugin' export const User = objectType({ name: 'User', definition(t) { t.int('id', { nullable: false }) t.string('email', { nullable: false }) t.string('name', { nullable: true }) }, }) export const Query = queryField('me', { type: 'Int', validate(root, args, { yup }, info) { // return yup schema and plugin will call schema.validateSync(args) return yup.object({ id: yup.number().min(2).max(3), name: yup.string().min(2).max(3), }) }, args: { id: intArg({ validate({ value, yup }) { // do validation by your self and when throw error plugin will catch it return yup.number().min(2).max(3).validateSync(value) }, }), name: stringArg({ validate({ value, yup }) { // return boolean.
Nexus Schema
nexusjs.org › docs › plugins › connection
Relay Connection - Plugins
The queryField or mutationField helpers may accept a function rather than a field name, which will be shorthand for the query builder:
GitHub
github.com › graphql-nexus › nexus › issues › 132
Root `Query` type should not be required when we use queryField · Issue #132 · graphql-nexus/nexus
May 5, 2019 - When we use queryField only, Nexus should not warn about: Nexus: You should define a root Query type for your schema Am I correct?
Author graphql-nexus
Nexus Schema
nexusjs.org › docs › api › object-type
objectType
Why Nexus? Examples · Guides · Schema · Nullability · Source Types · Abstract Types · Library Authors · Best Practices · Generated Artifacts · API · Introduction · objectType · subscriptionType · unionType · scalarType · interfaceType · enumType · inputObjectType · args · list / nonNull · makeSchema · extendType · mutationField · queryField ...