i have initated pmt , added a tenant . and added the
prisma = await multiTenant.get('test')
inside the context (btw i use nexus , nexus-plugin-prisma , apollo)
here is the full error
Invalid prisma.tenant.findOne() invocation:
Error querying the database: db error: ERROR: zero-length delimited identifier at or near """"
at PrismaClientFetcher.request (D:\7SSCarRentalProject2\CarRental-Backend\node_modules\.prisma-multi-tenant\management\runtime\
index.js:78543:15)
at processTicksAndRejections (internal/process/task_queues.js:97:5) {
clientVersion: '2.10.1'
}
PrismaClientInitializationError2:
Here is my full scenario
D:\7SSCarRentalProject2\CarRental-Backend>pmt init --verbose
Installing `@prisma-multi-tenant/client` as a dependency in your app...
$> yarn add --ignore-workspace-root-check @prisma-multi-tenant/client@2.4.2
warning " > @nexus/schema@0.17.0" has unmet peer dependency "graphql@^15.3.0".
warning " > apollo-server@2.19.0" has unmet peer dependency "graphql@^0.12.0 || ^0.13.0 || ^14.0.0 || ^15.0.0".
warning "apollo-server > apollo-server-core@2.19.0" has unmet peer dependency "graphql@^0.12.0 || ^0.13.0 || ^14.0.0 || ^15.0.0".
warning "apollo-server > apollo-server-express@2.19.0" has unmet peer dependency "graphql@^0.12.0 || ^0.13.0 || ^14.0.0 || ^15.0.0"
.
warning "apollo-server > graphql-subscriptions@1.1.0" has unmet peer dependency "graphql@^0.10.5 || ^0.11.3 || ^0.12.0 || ^0.13.0 |
| ^14.0.0".
warning "apollo-server > graphql-tools@4.0.8" has unmet peer dependency "graphql@^0.13.0 || ^14.0.0 || ^15.0.0".
warning "apollo-server > apollo-server-core > apollo-cache-control@0.11.4" has unmet peer dependency "graphql@^0.12.0 || ^0.13.0 ||
^14.0.0 || ^15.0.0".
warning "apollo-server > apollo-server-core > apollo-graphql@0.6.0" has unmet peer dependency "graphql@^14.2.1 || ^15.0.0".
warning "apollo-server > apollo-server-core > apollo-server-errors@2.4.2" has unmet peer dependency "graphql@^0.12.0 || ^0.13.0 ||
^14.0.0 || ^15.0.0".
warning "apollo-server > apollo-server-core > apollo-server-plugin-base@0.10.2" has unmet peer dependency "graphql@^0.12.0 || ^0.13
.0 || ^14.0.0 || ^15.0.0".
warning "apollo-server > apollo-server-core > apollo-server-types@0.6.1" has unmet peer dependency "graphql@^0.12.0 || ^0.13.0 || ^
14.0.0 || ^15.0.0".
warning "apollo-server > apollo-server-core > apollo-tracing@0.12.0" has unmet peer dependency "graphql@^0.12.0 || ^0.13.0 || ^14.0
.0 || ^15.0.0".
warning "apollo-server > apollo-server-core > graphql-extensions@0.12.6" has unmet peer dependency "graphql@^0.12.0 || ^0.13.0 || ^
14.0.0 || ^15.0.0".
warning "apollo-server > apollo-server-core > graphql-tag@2.11.0" has unmet peer dependency "graphql@^0.9.0 || ^0.10.0 || ^0.11.0 |
| ^0.12.0 || ^0.13.0 || ^14.0.0 || ^15.0.0".
warning "apollo-server > apollo-server-core > graphql-upload@8.1.0" has unmet peer dependency "graphql@0.13.1 - 14".
warning "apollo-server > apollo-server-core > subscriptions-transport-ws@0.9.18" has unmet peer dependency "graphql@>=0.10.0".
warning "apollo-server > graphql-tools > apollo-link@1.2.14" has unmet peer dependency "graphql@^0.11.3 || ^0.12.3 || ^0.13.0 || ^1
4.0.0 || ^15.0.0".
warning "apollo-server > graphql-tools > apollo-utilities@1.3.4" has unmet peer dependency "graphql@^0.11.0 || ^0.12.0 || ^0.13.0 |
| ^14.0.0 || ^15.0.0".
warning " > graphql-middleware@4.0.2" has unmet peer dependency "graphql@^0.12.0 || ^0.13.0 || ^14.0.0".
warning " > graphql-shield@7.3.6" has unmet peer dependency "graphql@^0.11.0 || ^0.12.0 || ^0.13.0 || ^14.0.0 || ^15.0.0".
warning " > nexus-plugin-prisma@0.23.1" has unmet peer dependency "@prisma/client@2.10.0".
warning " > nexus-plugin-prisma@0.23.1" has unmet peer dependency "graphql@^15.3.0".
warning " > request-promise@4.2.6" has unmet peer dependency "request@^2.34".
warning "request-promise > request-promise-core@1.1.4" has unmet peer dependency "request@^2.34".
warning " > graphql-request@3.3.0" has unmet peer dependency "graphql@14.x || 15.x".
warning " > @prisma-multi-tenant/client@2.4.2" has unmet peer dependency "@prisma/cli@^2.10.1".
We will now configure the management database:
? Management database url: postgresql://postgres:123456@localhost:5432/managment?schema=public
? Are you sure of your inputs? Yes
Updating .env and schema.prisma files...
Generating prisma clients for both management and tenants...
$> node "D:\7SSCarRentalProject2\CarRental-Backend\node_modules\@prisma\cli\build\index.js" generate --schema prisma/schema.prism
a
Environment variables loaded from D:\7SSCarRentalProject2\CarRental-Backend\.env
Environment variables loaded from prisma\.env
Prisma schema loaded from prisma\schema.prisma
✔ Generated Prisma Client (version: 2.10.1) to .\node_modules\@prisma\client in 426ms
You can now start using Prisma Client in your code:
import { PrismaClient } from '@prisma/client'
// or const { PrismaClient } = require('@prisma/client')
const prisma = new PrismaClient()
Explore the full API: http://pris.ly/d/client
$> node "D:\7SSCarRentalProject2\CarRental-Backend\node_modules\@prisma\cli\build\index.js" generate --schema="D:\7SSCarRentalPro
ject2\CarRental-Backend\node_modules\@prisma-multi-tenant\shared\build\prisma\schema.prisma"
Environment variables loaded from D:\7SSCarRentalProject2\CarRental-Backend\.env
Environment variables loaded from ./prisma/.env
Prisma schema loaded from node_modules\@prisma-multi-tenant\shared\build\prisma\schema.prisma
✔ Generated Prisma Client (version: 2.10.1) to .\node_modules\.prisma-multi-tenant\management in 97ms
You can now start using Prisma Client in your code:
import { PrismaClient } from './node_modules.prisma-multi-tenant\management'
// or const { PrismaClient } = require('./node_modules.prisma-multi-tenant\management')
const prisma = new PrismaClient()
Explore the full API: http://pris.ly/d/client
Setting up management database...
$> node "D:\7SSCarRentalProject2\CarRental-Backend\node_modules\@prisma\cli\build\index.js" migrate up --create-db --experimenta
l --schema="D:\7SSCarRentalProject2\CarRental-Backend\node_modules\@prisma-multi-tenant\shared\build\prisma\schema.prisma"
Environment variables loaded from D:\7SSCarRentalProject2\CarRental-Backend\.env
Environment variables loaded from ./prisma/.env
Prisma schema loaded from node_modules\@prisma-multi-tenant\shared\build\prisma\schema.prisma
migrate up
Datamodel that will initialize the db:
datasource management {
provider = ["sqlite","mysql","postgresql"]
url = "***"
}
generator client {
provider = "prisma-client-js"
output = env("PMT_OUTPUT")
binaryTargets = ["native"]
}
model Tenant {
name String @id
url String
}
Checking the datasource for potential data loss...
Database Changes:
Migration Database actions Status
20200715225700-base 1 CreateTable statements. Done
You can get the detailed db changes with prisma migrate up --experimental --verb
ose
Or read about them here:
./migrations/20200715225700-base/README.md
Done with 1 migration in 237ms.
Creating first tenant from your initial schema...
Creating example script...
✅ Your app is now ready for multi-tenancy!
Next step: Create a new tenant with `prisma-multi-tenant new`
D:\7SSCarRentalProject2\CarRental-Backend>pmt new --verbose
? Name of the tenant: test
? Database url: postgresql://postgres:123456@localhost:5432/managment?schema=test
? Are you sure of your inputs? Yes
$> node "D:\7SSCarRentalProject2\CarRental-Backend\node_modules\@prisma\cli\build\index.js" migrate up --create-db --schema prism
a/schema.prisma --experimental
Environment variables loaded from D:\7SSCarRentalProject2\CarRental-Backend\.env
Environment variables loaded from prisma\.env
Prisma schema loaded from prisma\schema.prisma
migrate up
Checking the datasource for potential data loss...
Database Changes:
Database Changes:
Database Changes:
Migration Database actions Status
20201031232715-t1 45 CreateTable statements. Done
20201031232753-t3 statements. Done
You can get the detailed db changes with prisma migrate up --experimental --verb
ose
Or read about them here:
./migrations/20201031232715-t1/README.md
./migrations/20201031232753-t3/README.md
Done with 2 migrations in 1.38s.
✅ Registered the new tenant into management and migrated up the database!
$ cross-env NODE_ENV=development tsnd --no-notify --respawn --transpile-only ./src
[INFO] 07:00:05 ts-node-dev ver. 1.0.0 (using ts-node ver. 9.0.0, typescript ver. 4.0.3)
Warning: nexus-plugin-prisma@0.23.1 does not support @prisma/client@2.10.1. The supported range is: `2.10.0`. This could lead to un
defined behaviors and bugs.
� Server ready at http://localhost:4000/
� Subscriptions ready at ws://localhost:4000/graphql
PrismaClientInitializationError2:
Invalid `prisma.tenant.findOne()` invocation:
Error querying the database: db error: ERROR: zero-length delimited identifier at or near """"
at PrismaClientFetcher.request (D:\7SSCarRentalProject2\CarRental-Backend\node_modules\.prisma-multi-tenant\management\runtime\
index.js:78543:15)
at processTicksAndRejections (internal/process/task_queues.js:97:5) {
clientVersion: '2.10.1'
}
My code 👍
export const createContext = async (ctx: any): Promise<Context> => {
let userId: number
let prisma;
try {
let Authorization = ''
try {
// for queries and mutations
Authorization = ctx.req.get('Authorization')
} catch (e) {
// specifically for subscriptions as the above will fail
Authorization = ctx?.connection?.context?.Authorization
}
const multiTenant = new MultiTenant()
const token = Authorization?.replace('Bearer ', '')
const verifiedToken = token && verify(token, APP_SECRET) as Token
prisma = await multiTenant.get('test')
if (!verifiedToken.userId && verifiedToken.type !== tokens.access.name)
userId = -1
else userId = verifiedToken.userId
} catch (e) {
console.log(e)
userId = -1
}
return {
...ctx,
prisma ,
pubsub,
userId,
}
}
I have downloaded the latest pmt version V2.4.2
i have initated pmt , added a tenant . and added the
prisma = await multiTenant.get('test')
inside the context (btw i use nexus , nexus-plugin-prisma , apollo)
here is the full error Invalid
prisma.tenant.findOne()
invocation:Here is my full scenario
import { PrismaClient } from '@prisma/client' // or const { PrismaClient } = require('@prisma/client')
const prisma = new PrismaClient()
import { PrismaClient } from './node_modules.prisma-multi-tenant\management' // or const { PrismaClient } = require('./node_modules.prisma-multi-tenant\management')
const prisma = new PrismaClient()
My code 👍