Next.js Discord

Discord Forum

API handler should not return a value, received object. But i'm forced to....

Unanswered
Havana posted this in #help-forum
Open in Discord
HavanaOP
I'm using graphql pothos ^3.30.0 to build my graphql apis (apollo server) in nextjs ^13.4.19. I recently updated nextjs and now i'm getting warnings for all of my endpoints which previously worked:
API handler should not return a value, received object.
What am i supposed to do?
This is an example of my builders:

builder.queryField('getClientsList', (t) =>
    t.prismaField({
        type: ['Client'],
        resolve: async (query, _parent, _args, _info) =>
            prisma.client.findMany({
                ...query,
            })
    })
)
export const schema = builder.toSchema()

this is my graphql endpoint using the old pages api (i'm using both App router and pages api for legacy stuff that i don't have time to troubleshoot)
import {schema} from "@/pages/api/schema";
import {ApolloServer} from "@apollo/server";
import {startServerAndCreateNextHandler} from "@as-integrations/next";
import {ApolloServerPluginLandingPageDisabled} from "@apollo/server/plugin/disabled";

export const dynamic = true;
const server = new ApolloServer({
    schema,
    introspection: process.env.NODE_ENV === 'development',
    plugins: process.env.NODE_ENV === 'development' ? [] : [ApolloServerPluginLandingPageDisabled()],
});

export default startServerAndCreateNextHandler(server, {
    context: async (req, res) => ({req, res}),
});

4 Replies

HavanaOP
this is how the builder is created:
import SchemaBuilder from "@pothos/core";
import PrismaPlugin from "@pothos/plugin-prisma";
import prisma from "@/lib/prisma";
// @ts-ignore
import type PrismaTypes from "@pothos/plugin-prisma/generated";
import {NextApiRequest, NextApiResponse} from "next";
import {Prisma} from "@prisma/client";

const builder = new SchemaBuilder<{
    Context: {
        req: NextApiRequest;
        res: NextApiResponse;
    }
    PrismaTypes: PrismaTypes;
}>({
    plugins: [PrismaPlugin],
    prisma: {
        client: prisma,
        dmmf: Prisma.dmmf
    }
})


export default builder

// We create empty root query, mutation, and subscription
// because we'll define individual nodes in other files
// since those nodes can have multiple resolvers and possibly
// can lead to really large and hard to read/navigate files
builder.queryType();
builder.mutationType();

The only reason i'm using this graphql hell is because it's an exercise, otherwise i would have never used graphql
HavanaOP
help?
HavanaOP
no eh?
HavanaOP
thanks