Open terion-name opened 5 years ago
Hey @terion-name 👋,
Could you explain in a bit more detail what you have in mind with executeRaw
?
@terion-name I believe this hasn't been implemented after all. I checked the schema which is exposed by Prisma instance itself, and there seems to be no executeRaw
field in any of the types.
Please note that prisma-binding
doesn't give any additional functionality to one already exposed by Prisma.
@maticzav it was: https://github.com/prisma/prisma/releases/tag/1.17.0
Hey @terion-name, I cannot reproduce your issue. Prisma Binding correctly generates executeRaw
for me. Here's the code I get;
prisma.mutation.executeRaw({
query: ""
})
I advise you check out the instructions in the documentation. I followed them, and it seems to be working. I hope they help you as well 🙂
In case they don't, please compose a CodeSandbox or a simple Github repo with reproduction.
Additionally, I would like to point out this is not connected to prisma-binding
. Codegen is not bound to Prisma but rather simply obtains the schema from the remote endpoint
and generates definitions for every field it can find. No extra field exists in prisma-binding
or is omitted by it. It merely mirrors the schema.
https://www.prisma.io/docs/prisma-graphql-api/reference/raw-database-access-qwe4/
@maticzav hm. I've tried, but it didn't work. This is strange, I'll check once more. Thank you
@terion-name, are you trying to use executeRaw
on Prisma hosted server, or self-hosted instance?
@maticzav self-hosted (1.19 running in docker)
@terion-name I am unable to reproduce your issue. Did you restart the docker
and included executeRaw
option from Prisma documentation? Could you compose a reproduction repository or CodeSandbox? Whichever suits you best! Otherwise, there is scarcely a chance to resolve this issue.
Can you try to regenerate your schema.graphql ? I had this issue and my schema.graphql was too old.
According to prisma doc, your files should look like this :
.graphqlconfig.yml
projects:
db:
schemaPath: "src/schema.graphql"
extensions:
prisma: prisma.yml
prisma.yml
datamodel: datamodel.prisma
endpoint: http://localhost:4466/myservice/dev
secret: mysecret
hooks:
post-deploy:
- graphql get-schema --project db
Running prisma deploy
will regenerate your schema.graphql.
Try searching executeRaw in it.
Now, use the generated schema.graphql as the typedef argument of your Prisma instance :
import typeDefs from "./schema.graphql"
const prisma = new Prisma({
typeDefs,
endpoint: https://localhost:4466/myservice/dev
secret: mysecret
});
You now have access to executeRaw in prisma.mutation.executeRaw.
my prisma-binding also doesn't expost executeRaw , prisma server version 1.28
I added to my prisma config rawAccess: true
flag:
PRISMA_CONFIG:
port: 4466
databases:
default:
connector: mysql
host: mysql
port: 3306
user: root
password: prisma
migrations: true
rawAccess: true
With prisma deploy I regerated the prisma.graphql
schema:
prisma deploy --force --env-file .env.local
Now in the prisma.graphql
file the executeRaw is added as mutation:
type Mutation {
executeRaw(database: PrismaDatabase, query: String!): Json!
}
From this point you can reach executeRaw function from prisma-binding:
const { Prisma } = require('prisma-binding')
const db = new Prisma({ typeDefs: process.env.PRISMA_SCHEMA || 'src/generated/prisma.graphql', endpoint: process.env.PRISMA_ENDPOINT, debug: process.env.PRISMA_DEBUG, secret: process.env.PRISMA_SECRET })
db.mutation.executeRaw({
query: 'CREATE INDEX Agent_heartbeat_IDX USING BTREE ON dev2
.Agent (heartbeat);'
})
I hope it helped.
Why does
executeRaw
is not supported here?Using Prisma client is not an option for my case. Can this be added?