title: GraphQL with Prisma: how to make a delete mutation
body: <p>I am trying to figure out how to make a delete mutation in my app.</p>
  <p>I have an Issue Service, Issue Resolver, and Issue Form.</p>
  <p>The service has:</p>
  <pre><code>import { prisma } from &quot;../../lib/prisma&quot;
  import { Service } from &quot;typedi&quot;
  import { IssueInput } from &quot;./inputs/create.input&quot;
  import { Resolver } from &quot;type-graphql&quot;
  import { Issue } from &quot;./issue.model&quot;
  
  @Service()
  @Resolver(() =&gt; Issue)
  export class IssueService {
    async createIssue(data: IssueInput) {
      return await prisma.issue.create({ data })
    }
  
    async getAllIssues() {
      return await prisma.issue.findMany()
    }
   
   
  
    async getIssue(id: string) {
      return await prisma.issue.findUnique({ where: { id } })
    }
  
    async deleteIssue(id: string) {
      return await prisma.issue.delete({ where: { id } })
    }
  }
  </code></pre>
  <p>The resolver has:</p>
  <pre><code>import { Arg, Mutation, Query, Resolver } from &quot;type-graphql&quot;
  import { Issue } from &quot;./issue.model&quot;
  import { IssueService } from &quot;./issue.service&quot;
  import { IssueInput } from &quot;./inputs/create.input&quot;
  import { Inject, Service } from &quot;typedi&quot;
  
  @Service()
  @Resolver(() =&gt; Issue)
  export default class IssueResolver {
    @Inject(() =&gt; IssueService)
    issueService: IssueService
  
    @Query(() =&gt; [Issue])
    async allIssues() {
      return await this.issueService.getAllIssues()
    }
  
   
  
  
    @Query(() =&gt; Issue)
    async issue(@Arg(&quot;id&quot;) id: string) {
      return await this.issueService.getIssue(id)
    }
  
    @Mutation(() =&gt; Issue)
    async createIssue(@Arg(&quot;data&quot;) data: IssueInput) {
      return await this.issueService.createIssue(data)
    }
  
    @Mutation(() =&gt; Issue)
    async deleteIssue(@Arg(&quot;id&quot;) id: string)  {
      return await this.issueService.deleteIssue(id)
    }
  }
  </code></pre>
  <p>My lib/graphql sort of recognises that I tried to make the mutations. It has entries as follows:</p>
  <pre><code>export type Mutation = {
    __typename?: 'Mutation';
    createIssue: Issue;
    deleteIssue: Issue;
  
  export type MutationDeleteIssueArgs = {
    id: Scalars['String'];
  };
  </code></pre>
  <p>Apart from the above two references, the lib/graphql does not have something that looks like the other mutations and queries.</p>
  <p>In the issue form, I want to try and use the delete mutation, so I tried:</p>
  <pre><code>import {
    IssueInput,
    useAllIssuesQuery,
    useCreateIssueMutation,
    useDeleteIssueMutation, ## this is not recognised as an exported member of lib/graphql
    
  } from &quot;lib/graphql&quot;
  </code></pre>
  <p>How can I add it to the lib/graphql. Whatever the process for generating the mutation was has obviously run, but I don't understand why it didn't make something I can use in the form.</p>
  <p>My goal is to try and figure out how to write something along the following lines to try and delete an entry.</p>
  <pre><code> { onDelete: async (id) =&gt; {
           await fetch(&quot;api/issue&quot;, { method: &quot;delete&quot; }),
             toast({
               title: &quot;Issue deleted&quot;,
              
             })
           refetch()
         refetchClimate()
         }
         }
  </code></pre>