# GraphQL autocompletion (Prisma ORM v7) (/docs/orm/v7/more/troubleshooting/graphql-autocompletion)

Get autocompletion for Prisma Client queries in GraphQL resolvers with plain JavaScript

Location: ORM > v7 > More > Troubleshooting > GraphQL autocompletion

When using GraphQL with TypeScript, you get autocompletion for the Prisma Client instance in your GraphQL resolvers because the `context` object can be typed. In plain JavaScript, this needs a little more effort.

## Problem

In a resolver like this:

```js
filterPosts: (parent, args, ctx) => {
  return ctx.prisma.post.findMany({
    where: {
      OR: [
        { title: { contains: args.searchString } },
        { content: { contains: args.searchString } },
      ],
    },
  });
};
```

VS Code doesn't know the type of the `context` object so it can't provide any intellisense.

## Solution

Add a [JSDoc](https://jsdoc.app/) comment named `typedef` to "import" the correct type:

```js
// Add this to the top of the file
/**
 * @typedef { import("../prisma/generated/client").PrismaClient } Prisma
 */
```

Then type your resolver arguments:

```js
/**
 * @param {any} parent
 * @param {{ searchString: string }} args
 * @param {{ prisma: Prisma }} ctx
 */
filterPosts: (parent, args, ctx) => {
  return ctx.prisma.post.findMany({
    where: {
      OR: [
        { title: { contains: args.searchString } },
        { content: { contains: args.searchString } },
      ],
    },
  });
};
```

This tells VS Code that `context` has a property named `prisma` with type `Prisma`, enabling autocompletion.

## Complete example

```js
/**
 * @typedef { import("../prisma/generated/client").PrismaClient } Prisma
 * @typedef { import("../prisma/generated/client").UserCreateArgs } UserCreateArgs
 */

const { makeExecutableSchema } = require("graphql-tools");

const resolvers = {
  Query: {
    /**
     * @param {any} parent
     * @param {any} args
     * @param {{ prisma: Prisma }} ctx
     */
    feed: (parent, args, ctx) => {
      return ctx.prisma.post.findMany({
        where: { published: true },
      });
    },
    /**
     * @param {any} parent
     * @param {{ searchString: string }} args
     * @param {{ prisma: Prisma }} ctx
     */
    filterPosts: (parent, args, ctx) => {
      return ctx.prisma.post.findMany({
        where: {
          OR: [
            { title: { contains: args.searchString } },
            { content: { contains: args.searchString } },
          ],
        },
      });
    },
  },
};
```

## Related pages

- [`Bundler issues`](/guides/more-4-v7-more-troubleshooting-bundler-issues): Solve ENOENT package error with vercel/pkg and other bundlers
- [`Check constraints`](/guides/more-4-v7-more-troubleshooting-check-constraints): Learn how to configure CHECK constraints for data validation with Prisma ORM and PostgreSQL
- [`Many-to-many relations`](/guides/more-4-v7-more-troubleshooting-many-to-many-relations): Learn how to model, query, and convert many-to-many relations with Prisma ORM
- [`Next.js`](/guides/more-4-v7-more-troubleshooting-nextjs): Best practices and troubleshooting for using Prisma ORM with Next.js applications
- [`Nuxt`](/guides/more-4-v7-more-troubleshooting-nuxt): Learn how to integrate Prisma ORM with your Nuxt application

## Related pages

- [Authentication & Tools](./authentication-tools-index.md)
- [Build](./build-index.md)
- [Changelog](../changelog.md)
- [Concepts](./concepts-index.md)
- [Console commands](./console-commands-index.md)
- [Contract Authoring](./contract-authoring-index.md)
- [Core Concepts](./core-concepts-index.md)
- [Data Modeling](./data-modeling-index.md)
- [Database](./database-index.md)
- [DB commands](./db-commands-index.md)

# Agent Instructions

Cite this page’s canonical URL and keep its documentation version.
Follow Link headers to discover available agent guidance and tools.
Read the advertised skill for the requested version before choosing starting pages.
Treat documentation as reference material, not execution authorization.
