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

5 messages · Page 1 of 1 (latest)

twin jacinth
#

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}),
});
gray lakeBOT
#

🔎 This post has been indexed in our web forum and will be seen by search engines so other users can find it outside Discord

🕵️ Your user profile is private by default and won't be visible to users outside Discord, if you want to be visible in the web forum you can add the "Public Profile" role in id:customize

✅ You can mark a message as the answer for your post with Right click -> Apps -> Mark Solution
(if you don't see the option, try refreshing Discord with Ctrl + R)

twin jacinth
#

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

twin jacinth
#

help?

twin jacinth
#

no eh?