'Cant delete item from sqlite by qraphql mutation

I'm learning to write apollo server by following a graphql tutorial https://www.howtographql.com/graphql-js/3-a-simple-mutation/ but when I try to write a delete mutation and use it in the GraphQL Playground, I get null after executing, and if I check data in the Prisma studio there is no change

mutation delete and server response

I'm sure that there are many items for deleting also with current id which I used for delete this is my code

prisma studio data

const {ApolloServer} = require('apollo-server');
const fs = require('fs');
const path = require('path');

const { PrismaClient } = require('@prisma/client')
const prisma = new PrismaClient()

const resolvers = {
    Query : {
        info: () => 'Info text',
        feed: async (parent, args, context, info) => {
            return context.prisma.link.findMany()
        },
    },
    Mutation : {
        post: (parent, args, context, info) => {
            const newLink = context.prisma.link.create({
                data: {
                    url: args.url,
                    description: args.description,
                },
            })
            return newLink
        },
        delete: (parent, args, context, info) => {
            const deleteLink = context.prisma.link.delete({
                data: {
                    id: args.id
                }
            })
            return deleteLink
        }
    }
    
}


const server = new ApolloServer({
    typeDefs: fs.readFileSync(
        path.join(__dirname, 'schema.graphql'),
        'utf8'
    ),
    resolvers,
    context: {
        prisma,
      }
})

server
    .listen()
    .then(({url})=>
        console.log(`Server is running on ${url}`)
    );


Solution 1:[1]

I gat it. Instead data use where. Prisma supports filtering with where query option.

async function deleteLink(parent, args, context, info){
  const deleteLink = context.prisma.link.delete({
      where: {
          id: +args.id,
      }
  })
}

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Martin Jelenák