prisma1 icon indicating copy to clipboard operation
prisma1 copied to clipboard

prisma export fails when no data is stored

Open marcovc opened this issue 8 years ago • 13 comments

Current behavior

prisma export fails.

Reproduction

$ prisma init hello-world
? How to set up a new Prisma service? 

Running $ graphql create ...                             
? Choose GraphQL boilerplate project: node-basic              Basic GraphQL server (incl. database)
[graphql create] Downloading boilerplate from https://github.com/graphql-boilerplates/node-graphql-server/archive/master.zip...
[graphql create] Installing node dependencies for /home/marco/projects/anf/inventory/prototype2/hello-world/package.json...
yarn install v1.3.2
warning package.json: No license field
warning graphql-boilerplate: No license field
[1/4] Resolving packages...
[2/4] Fetching packages...
info [email protected]: The platform "linux" is incompatible with this module.
info "[email protected]" is an optional dependency and failed compatibility check. Excluding it from installation.
[3/4] Linking dependencies...
warning "graphql-yoga > [email protected]" has unmet peer dependency "aws-lambda@^0.1.2".
warning "prisma-binding > [email protected]" has incorrect peer dependency "graphql@^0.11.0".
warning "graphql-cli > [email protected]" has unmet peer dependency "express@^4.16.2".
warning "prisma > prisma-cli-core > graphql-cli > [email protected]" has unmet peer dependency "express@^4.16.2".
[4/4] Building fresh packages...
Done in 2.78s.
[graphql create] Installing node dependencies for /home/marco/projects/anf/inventory/prototype2/hello-world/.install/package.json...
yarn install v1.3.2
warning package.json: No license field
warning ../package.json: No license field
warning [email protected]: No license field
[1/4] Resolving packages...
[2/4] Fetching packages...
[3/4] Linking dependencies...
warning " > [email protected]" has unmet peer dependency "[email protected]".
[4/4] Building fresh packages...
Done in 0.17s.
[graphql create] Running boilerplate install script... 
Running $ prisma deploy...

? Please choose the cluster you want to deploy "hello-world@dev" to 
Added cluster: local to prisma.yml
Creating stage dev for service hello-world ✔
Deploying service `hello-world` to stage `dev` on cluster `local` 64ms

Changes:

  Post (Type)
  + Created type `Post`
  + Created field `id` of type `GraphQLID!`
  + Created field `isPublished` of type `Boolean!`
  + Created field `title` of type `String!`
  + Created field `text` of type `String!`
  + Created field `updatedAt` of type `DateTime!`
  + Created field `createdAt` of type `DateTime!`

Applying changes 1.5s

Hooks:

Writing database schema to `src/generated/prisma.graphql`  46ms
Running $ graphql prepare...

Your GraphQL database endpoint is live:

  HTTP:  http://localhost:4466/hello-world/dev
  WS:    ws://localhost:4466/hello-world/dev


Next steps:
  1. Change directory: `cd hello-world`
  2. Start local server and open Playground: `yarn dev`

$ cd hello-world/
$ prisma export
Downloading nodes !
 â–¸    Cannot read property 'jsonElements' of undefined

Get in touch if you need help: https://www.graph.cool/forum
To get more detailed output, run $ export DEBUG="*"
Reply
  Bookmark  

Expected behavior?

prisma export is expected to work.

marcovc avatar Jan 26 '18 09:01 marcovc

Thanks for the report @marcovc. You should be able to add a node and then do prisma export to work around this issue 🙂

marktani avatar Jan 26 '18 09:01 marktani

No, sorry. I just added a post using the playground, and then retried prisma export and obtained the same error.

marcovc avatar Jan 26 '18 09:01 marcovc

Note the set of warnings above about "unmet dependencies" on "prisma init". Could it possibly be related?

marcovc avatar Jan 26 '18 09:01 marcovc

You're right, I can reproduce this myself.

Here's the debug output from the local cluster:

Downloading nodes...  client Downloading from http://localhost:4466/export/dev/export +0ms
  client {"fileType":"nodes","cursor":{"table":0,"row":0,"field":0,"array":0}} +1ms
  Exporter { code: 3016,
  Exporter   requestId: 'api:api:cjcvqky9s02n401796izv1fsk',
  Exporter   error: 'Project not found: \'export~dev@export\'' } +413ms
 !
TypeError: Cannot read property 'jsonElements' of undefined
    at Exporter.<anonymous> (/usr/local/lib/node_modules/prisma/node_modules/prisma-cli-core/src/commands/export/Exporter.ts:126:25)
    at step (/usr/local/lib/node_modules/prisma/node_modules/prisma-cli-core/dist/commands/export/Exporter.js:32:23)
    at Object.next (/usr/local/lib/node_modules/prisma/node_modules/prisma-cli-core/dist/commands/export/Exporter.js:13:53)
    at fulfilled (/usr/local/lib/node_modules/prisma/node_modules/prisma-cli-core/dist/commands/export/Exporter.js:4:58)
    at <anonymous>
    at process._tickDomainCallback (internal/process/next_tick.js:228:7)

marktani avatar Jan 26 '18 09:01 marktani

I'm also having troubles importing (that was what led me to try exporting first), perhaps it is related...

marcovc avatar Jan 26 '18 09:01 marcovc

Thanks a lot for your help @marcovc! I digged deeper, and I believe the issue to be this one: #1743. I'll wait until this is fixed and will revisit the issue you've raised afterwards.

marktani avatar Jan 26 '18 10:01 marktani

Is there any workaround for me at the moment?

marcovc avatar Jan 26 '18 10:01 marcovc

I was able to modify my local installation of prisma, and force it to download docker image 1.0.1 instead of 1.0 (according to the issue you mentioned). It works now. Thanks

marcovc avatar Jan 26 '18 11:01 marcovc

@marcovc how did you do this? I'm having the same issue

ramsaylanier avatar Jan 26 '18 15:01 ramsaylanier

@ramsaylanier I had to edit this file:

/usr/lib/node_modules/prisma/node_modules/prisma-cli-core/dist/commands/local/docker/docker-compose.yml

since I have prisma installed globally. I guess it should be

./node_modules/prisma/node_modules/prisma-cli-core/dist/commands/local/docker/docker-compose.yml

in case you have it locally installed.

Search for

prisma-database:
    image: prismagraphql/prisma:1.0.1

marcovc avatar Jan 26 '18 15:01 marcovc

Awesome! Works now. Thanks @marcovc

ramsaylanier avatar Jan 26 '18 15:01 ramsaylanier

Update Prisma to the latest 1.0.10 version, at least "prisma playground" works.

limux avatar Jan 28 '18 00:01 limux

This is fixed in the latest release, please run npm install -g prisma and prisma local upgrade, and ensure that you're on 1.1.x using prisma cluster list.

marktani avatar Feb 01 '18 18:02 marktani