Prisma1: Document Prisma JS API (equivalent of Prisma CLI API but for JS)

Created on 12 Apr 2018  路  5Comments  路  Source: prisma/prisma1

Hi,

Here is my use case:

I want to automate tests, using the Jest framework. Before each test I can run a JS file to setup the graphql database. I would like, in this JS file, to be able to run commands such as prisma reset and prisma import.

Of course I could do it using exec to run the CLI command from JS. but this is dirty.

I believe it is possible to access prisma-cli-core functions (or similar) from JS without having to spawn new processes. However there is no documentation related to that. I tried reading files such as https://github.com/graphcool/prisma/blob/master/cli/packages/prisma-cli-core/src/commands/reset/reset.ts but I am not sure this will work properly, and there is not documentation to call this function programmatically from js, as opposed to from the CLI.

aredocs

Most helpful comment

@crubier for now instead of calling exec() I'm using fetch:

await fetch("http://prisma:4466/private", {
    body: JSON.stringify({ query: "mutation { resetData }" }),
    headers: { "content-type": "application/json" },
    method: "post",
});

hope it helps

All 5 comments

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

Bump for the bot

I believe a good documentation should include testing part, and this feature is required when writing functional tests :+1:

@crubier for now instead of calling exec() I'm using fetch:

await fetch("http://prisma:4466/private", {
    body: JSON.stringify({ query: "mutation { resetData }" }),
    headers: { "content-type": "application/json" },
    method: "post",
});

hope it helps

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

MitkoTschimev picture MitkoTschimev  路  3Comments

sorenbs picture sorenbs  路  3Comments

marktani picture marktani  路  3Comments

jannone picture jannone  路  3Comments

hoodsy picture hoodsy  路  3Comments