Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ESLint integration - Unsafe call of an any typed value #1065

Open
fastmx opened this issue Mar 24, 2021 · 1 comment
Open

ESLint integration - Unsafe call of an any typed value #1065

fastmx opened this issue Mar 24, 2021 · 1 comment

Comments

@fastmx
Copy link

fastmx commented Mar 24, 2021

Hello,
I'm trying to configure TS+ESLint with nexus-plugin prisma. No luck so far with it, I'm getting this error:

ESLint: Unsafe call of an any typed value.(@typescript-eslint/no-unsafe-call)

image

Is there anyone who made this work?


Here is my configuration:

Prisma model:

model Company {
    id Int @default(autoincrement()) @id
    symbol String
    name String
    description String
}

Nexus

const Company = objectType({
  name: "Company",
  definition(t) {
    t.model.id();
    t.model.name();
    t.model.description();
  }
});

const Query = queryType({
  definition(t) {
    t.field("company", {
      type: Company,
      args: { id: idArg() },
      resolve: (_root, { id }, ctx) => ctx.prisma.company.findUnique({ where: { id: Number(id) } })
    });
  }
});

const schema = makeSchema({
  types: [Query, Company],
  plugins: [nexusPrisma({ experimentalCRUD: true })],
  outputs: {
    schema: path.join(process.cwd(), "generated", "schema.gen.graphql"),
    typegen: path.join(process.cwd(), "generated", "nexusTypes.gen.ts")
  },
  // sourceTypes: { modules: [{ module: ".prisma/client", alias: "PrismaClient" }] },
  contextType: {
    module: path.join(process.cwd(), "src", "graphql", "context.ts"),
    export: "Context"
  },
  sourceTypes: {
    modules: [
      {
        module: "@prisma/client",
        alias: "prisma"
      }
    ]
  }
});

Packages:

  "dependencies": {
    "@prisma/client": "2.18.0",
    "@typescript-eslint/eslint-plugin": "^4.18.0",
    "@typescript-eslint/parser": "^4.18.0",
    "apollo-server-micro": "^2.21.1",
    "babel-eslint": "^10.1.0",
    "eslint": "^7.22.0",
    "eslint-config-airbnb": "^18.2.1",
    "eslint-config-airbnb-base": "^14.2.1",
    "eslint-config-airbnb-typescript": "^12.3.1",
    "eslint-config-prettier": "^7.2.0",
    "eslint-plugin-flowtype": "^5.4.0",
    "eslint-plugin-import": "^2.22.1",
    "eslint-plugin-jest": "^24.3.2",
    "eslint-plugin-jsx-a11y": "^6.4.1",
    "eslint-plugin-prettier": "^3.3.1",
    "eslint-plugin-react": "^7.22.0",
    "eslint-plugin-react-hooks": "^4.2.0",
    "graphql": "^15.5.0",
    "next": "10.0.9",
    "nexus": "^1.0.0",
    "nexus-plugin-prisma": "^0.32.0",
    "prettier": "^2.2.1",
    "prisma": "2.18.0",
    "react": "17.0.1",
    "react-dom": "17.0.1"
  },
@Akxe
Copy link

Akxe commented Apr 22, 2021

You are using the plugin wrong, you must let it create the type definition file that will fix this error.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants