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

Issue with Prisma binding #164

Closed
marktani opened this issue May 11, 2018 · 45 comments
Closed

Issue with Prisma binding #164

marktani opened this issue May 11, 2018 · 45 comments

Comments

@marktani
Copy link
Contributor

@OGNeutron commented on Fri May 11 2018

When I graphql-prepare I am getting a type issue with Prisma in prisma.ts


Property 'query' in type 'Prisma' is not assignable to the same property in base type 'Prisma'.
  Type 'Query' is not assignable to type 'QueryMap'

@marktani commented on Fri May 11 2018

Please share a minimal reproduction so we can look into this 🙂


@OGNeutron commented on Fri May 11 2018

Alright, I just do the normal prisma deploy, the database sets up fine and even the post hooks show fine:

post-deploy:
Running graphql get-schema --project db √
Running graphql prepare √

But they don't actually generate the files, so I do it manually and it shows up, but than I get that issue with the prisma.ts file where all three, query, mutation and subscriptions give similar errors.

[ts]
Property 'mutation' in type 'Prisma' is not assignable to the same property in base type 'Prisma'.
  Type 'Mutation' is not assignable to type 'QueryMap'.
    Property 'createNotification' is incompatible with index signature.
      Type '(args: { data: NotificationCreateInput; }, info?: string | GraphQLResolveInfo) => Promise<Notific...' is not assignable to type '(args?: { [key: string]: any; }, context?: { [key: string]: any; }, info?: string | GraphQLResolv...'.
        Types of parameters 'info' and 'context' are incompatible.
          Type '{ [key: string]: any; }' is not assignable to type 'string | GraphQLResolveInfo'.
            Type '{ [key: string]: any; }' is not assignable to type 'GraphQLResolveInfo'.

https://github.com/OGNeutron/Prisma_main_hub

@abelovic
Copy link

I am getting this as well... the post deploy hooks don't seem to work :(

If I run in a script: "prisma deploy && graphql get-schema && graphql prepare" it generates the file as expected

@timsuchanek
Copy link
Contributor

Thanks for reporting! prisma-binding@2 is not meant to be used with graphql prepare, but graphql codegen. My apologies if we didn't communicate that clearly.
To make graphql codegen possible, you also need to configure your .graphqlconfig.yml.
Here is an example of a running project that uses graphql codegen together with the new prisma-binding@2:
https://github.com/graphql-binding/graphql-binding/tree/master/examples/full-example

I let this issue open as a reminder for us to create better docs.

Would be cool to get your feedback @marktani & @abelovic if switching to graphql codegen works in your use case.

@NeutronScott12
Copy link

NeutronScott12 commented May 14, 2018

Alright might need a slight guide on how to implement this because the example is a bit different to mine, I copied the part of the graphqlconfig.yml relevant to Prisma, but it doesn't seem to generate now with graphql get-schema or graphql codegen but runs fine without errors.

https://github.com/OGNeutron/Prisma_main_hub

@abelovic
Copy link

abelovic commented May 14, 2018

@timsuchanek - I am having trouble getting this to work as well using the graphql boilerplates structure that most of us are using. Here is my graphqlconfig:

When I run the following config I get: "Couldn’t find prisma.yml file. Are you in the right directory?" Not sure why I am getting this when I have set the path :/

  app:
    schemaPath: src/schema.graphql
    extensions:
      endpoints:
        default: http://localhost:4000
  db: #Is this supposed to be "db" or "database" - was database before? I tried both btw
    schemaPath: src/generated/prisma.graphql
    extensions:
      prisma: database/prisma.yml
      codegen:
       generator: prisma-binding
         language: javascript
         input: schema.js #What is this? Are we supposed to add this file? Is this because you are not running import-loader package in your example?
         output:
           binding: src/generated/prisma.js




@abelovic
Copy link

Running this doesn't give the error but doesn't generate the file either which I think is what @OGNeutron is running into as well:

  app:
    schemaPath: src/schema.graphql
    extensions:
      endpoints:
        default: http://localhost:4000
  database:
    schemaPath: src/generated/prisma.graphql
    extensions:
      prisma: database/prisma.yml
      codegen:
        - generator: prisma-binding
          language: javascript
          input: src/generated/prisma.graphql
          output:
            binding: src/generated/prisma.js

@steve-a-jones
Copy link

Running into similar errors .. Type '{}' is not assignable to type 'GraphQLResolveInfo'. Property 'fieldName' is missing in type '{}'... etc..

Would also love some clarity and better documentation around these configs... they are fairly esoteric and difficult to reason about. I would almost rather just have a few scripts to imperatively generate everything instead :)

@NeutronScott12
Copy link

NeutronScott12 commented May 15, 2018

Still haven't got it working with my current project, also not getting any errors or generated files, I tried different setups, I can get graphql get-schema working, but codegen just runs and shows nothing.

@SpaceK33z
Copy link

These docs are also out of date now. I'd help update the docs except I don't understand how prisma-binding@2 works at all.

@abelovic
Copy link

The whole 1.8 release seems too rushed considering there are so many breaking changes. This has caused so many problems for me. I pay for the prisma cloud and the whole point of this is so I can forget about it and it just works. This has been far from the truth. This is now consuming 90% of my time because it seems like every time I upgrade something breaks. Since this is the DAL/ORM (or whatever you want to call it) it basically cripples my app development until I can resolve it :( The prisma team needs to consider doing pre-releases and properly test/document this stuff before releasing to the masses. I do not want to pay to be a beta tester for prisma.

@alvis
Copy link
Contributor

alvis commented May 16, 2018

I'm feeling the same. Breaking changes are fine, but you need documentation! At least the team should give us a migration guide for anything changed. Spending 90% of my time to trace what's breaking is breaking my heart to Prisma.

@alvis
Copy link
Contributor

alvis commented May 16, 2018

After hours of researching, the following finally seems working for prisma-blinding 2.0.

projects:
  app:
    schemaPath: source/schema.graphql
    extensions:
      endpoints:
        default: 'http://localhost:4000'
  database:
    schemaPath: source/generated/prisma.graphql
    extensions:
      prisma: database/prisma.yml
      codegen:
        generator: prisma-binding
        language: typescript
        output:
          binding: source/generated/prisma.ts

Note: the .graphqlconfig.yml above is for prisma-blinding 2.0 only. For 1.x, users can refer to the now completely outdated doc...

@sorenbs
Copy link

sorenbs commented May 16, 2018

@abelovic, @alvis and everybody else who has had a frustrating experience with the 1.7 and 1.8 releases:

You are absolutely right! Our release process has been too hectic and unfortunately this has resulted in us releasing buggy software and not being able to update the documentation in time.

We are doing two things to address this issue:

  1. We are investing heavily in updating existing documentation over the next 3-4 weeks. We have a long backlog of improvements to go through. We will get there.

  2. We are changing our release process to ensure that we have more time to test new releases and update the documentation. We will write more about this in an upcoming blog post.

I am really sorry about the frustrating experience and I promise you that we will do better in the future.

@alvis
Copy link
Contributor

alvis commented May 17, 2018

Got a problem with importing other .graphql files into the schema. With code gen, prisma-binding at the moment skips the import syntax in line 73:
https://github.com/prismagraphql/prisma-binding/blob/ef7fc575a8a5473db2f48574c488c71ca181bf9f/src/bin.ts#L71-L86

To fix it, we should wrap it with importSchema from graphql-import, i.e.

return buildSchema(importSchema(input))

@sorenbs: should I make a quick PR to fix it?

@timsuchanek
Copy link
Contributor

Thanks for the suggestion @alvis ! Yes, it would be awesome if you could do a PR for that :)

@abelovic : In the new prisma.yml you also need to add the following lines of code:

hooks:
  post-deploy:
    - graphql get-schema
    - graphql codegen

Here is a running example: https://github.com/graphql-binding/graphql-binding/blob/master/examples/full-example/prisma.yml

@NeutronScott12
Copy link

NeutronScott12 commented May 17, 2018

I've changed prisma.yml and graphqlconfig.yml but I am still getting no results, I am still getting this:

√ Code for project db generated to src/generated/prisma.ts

For some reason it's not generating the files

https://github.com/OGNeutron/Prisma_main_hub

@alvis
Copy link
Contributor

alvis commented May 17, 2018

I think the input field is unnecessary i.e. this should work

projects:
  app:
    schemaPath: "src/schema.graphql"
    extensions:
      endpoints:
        default: "http://localhost:4000"
  db:
    schemaPath: src/generated/prisma.graphql
    extensions:
      prisma: prisma.yml
      codegen:
        - generator: prisma-binding
          language: typescript
          output:
            binding: src/generated/ts-prisma.ts

My suggestion is to have the hook setup in your prisma.yml.

hooks:
  post-deploy:
    - graphql get-schema
    - graphql codegen

Then run prisma deploy to update and generate all desired files.

@NeutronScott12
Copy link

NeutronScott12 commented May 17, 2018

I've done that, I have added the input field, since I wrote that post, but it seems not to be working, also lately prisma deploy hasn't been working(except database migration), but running the graphql commands are working, get-schema runs perfectly, but codegen isn't working at all, if you want to clone my repo and give it a spin, I must be missing something.

@alvis
Copy link
Contributor

alvis commented May 17, 2018

@OGNeutron check out my fork of your repo
https://github.com/alvis/Prisma_main_hub

It should be working by running npm run deploy.

Note: Remember to change your endpoint in prisma.yml before deploying.

@abelovic
Copy link

abelovic commented May 17, 2018

@timsuchanek - yes I had the hooks but the problem I and @OGNeutron have is those hooks are not executing once prisma deploy finishes. They say they do (with no errors) but do not actually update either the prisma.graphql or the prisma.js files :(

I have rolled back to 1.7.4 and prisma-binding 1.5.19 for my project in the meantime. Everything works as expected so I suspect there is something going on in both the hooks and the codegen. If it's indeed a config issue on our end then it would be helpful if get-schema and codegen provide and error message.

Also thanks for your example but the majority of us use the boilerplates. I get you are trying to simplify the issue but there leaves too much room for configuration error (on our part) when we try to apply those changes. I already have lots of other things going on i.e. serverless, webpack, lambda as do I suspect most others do. @alvis and @OGNeutron repos are more useful because they are much closer to our real world implementations. Could you update yours? I think a webpack boilerplate is long overdue as well so hopefully @sorenbs has that on his roadmap hint hint :)

@alvis - thanks for providing a repo. I will try and check that out today and see if it helps :)

@NeutronScott12
Copy link

The changes didn't help, I still get the same response √ Code for project db generated to src/generated/ts-prisma.ts when doing graphql codegen and still not generating files, it's a weird issue.

@alvis
Copy link
Contributor

alvis commented May 17, 2018

@OGNeutron have you tried to clone the repo and redo everything from the start?

@NeutronScott12
Copy link

Cloned it, changed to my endpoints and so on, but I still can not get it to generate the prisma-bindings, nothing wrong with the graphql get-schema, are you saying you got it working? Because I couldn't with the forked version.

@agonbina
Copy link

I also have similar issues with the same configuration. Is it possible it could be due to environment dependencies like node.js or npm? Could be we're getting different versions of prisma-bindings dependencies

@alvis
Copy link
Contributor

alvis commented May 18, 2018

🤔 I tried to clone the repo to my another computer and it works as expected. I've node 10.1 both set up in my computers, but I don't think it's the cause.

@OGNeutron: did you run npm run deploy or simply graphql codegen?
@agonbina: are you using my repo?

@NeutronScott12
Copy link

Yeah, I've done it both ways, I've prisma deployed it and graphql codegen and I get the same response and I am also Node 10.1, and actually graphql get-schema only works if I do it manually, it doesn't work if I do prisma deploy, neither command works.

I get the same for the forked version and the one I've changed to be the same.

@agonbina
Copy link

I had two issues but now it is working 👍

First one was that prisma-bindings is using yargs@11.x and I had another top level dependency which was using a way older version of yargs. npm` installed only the older one when it flattened out dependencies so obviously prisma-bindings was throwing exceptions.

Second one was that the syntax I was using in the graphqlconfig.yml was wrong, specifically the codegen key is supposed to be an array (in YAML format) and I was using a map instead.

@NeutronScott12
Copy link

NeutronScott12 commented May 18, 2018

Can you show your graphqlconfig.yml so I can compare with mine, maybe I have a similar issue as-well?

@agonbina
Copy link

@OGNeutron here it is:

projects:
  app:
    schemaPath: src/schema.graphql
    extensions:
      endpoints:
        default: http://localhost:4000
  database:
    schemaPath: src/generated/prisma.graphql
    extensions:
      prisma: graph/prisma.yml
      codegen:
        - generator: prisma-binding
          language: typescript
          output:
            binding: src/generated/prisma.ts

@NeutronScott12
Copy link

NeutronScott12 commented May 18, 2018

It's the same one, my troubles continue with the adventures of OGNeutron, such a weird issue. Bloody codegen.

Well, when I start the server I am getting these wonderful wanings:

warning command codegen both exists in plugin C:\Users\Scott\AppData\Roaming\npm\node_modules\graphql-cli-codegen and is shipped with the graphql-cli.
The plugin is being ignored.
warning command prepare both exists in plugin E:\DeveloperStuff\MainProjects\main_hub_prisma\node_modules\graphql-cli-prepare and is shipped with the graphql-cli.

@alvis
Copy link
Contributor

alvis commented May 18, 2018

I'm suspecting windows be the cause of the problem? May be some of the packages are not working properly under windows?

@NeutronScott12
Copy link

NeutronScott12 commented May 18, 2018

I kinda got the server working, just missing those ts-types & prisma-binding which codegen is meant to provide, well I dual boot with Ubuntu so I will give it a spin on that, but I doubt it, giving that the other graphql commands work, I must be doing something wrong with codegen.

Also prisma deploy doesn't seem to work, have to manually call graphql commands.

@NeutronScott12
Copy link

NeutronScott12 commented May 18, 2018

Yep, it's a bug for Windows, I just tried it with Ubuntu 18.04 and it worked perfectly, for some reason it doesn't work for Windows, I am 1709(I believe latest) and it seems to be the main cause for why prisma deploy or codegen isn't working.

@medelman17
Copy link
Contributor

Interesting. Maybe an issue related to how environment variables are handled?

@alvis
Copy link
Contributor

alvis commented May 19, 2018

@timsuchanek: just to let you know that a PR (#169) is made for supporting import in codegen.

@hyrecar
Copy link

hyrecar commented May 23, 2018

I'm having the same issue on a mac:

Running graphql codegen --dotenv ../../.env ✔
warning command prepare both exists in plugin /Users/rohitravikoti/Documents/hyrecar/services/node_modules/graphql-cli-prepare and is shipped with the graphql-cli.
The plugin is being ignored.

@alvis
Copy link
Contributor

alvis commented May 27, 2018

@hyrecar: could you make a repo for us to check?

@hyrecar
Copy link

hyrecar commented May 28, 2018

@alvis, I realized that my case is actually different from this issue. For my case, I am actually generating bindings for the gateway which wraps the prisma schema. So the codegen works for the prisma binding itself, but when I try to do it for the wrapper, it's giving me the issues. I'll dig deeper into it and find out exactly what is going on.

@Kisepro
Copy link

Kisepro commented May 30, 2018

@OGNeutron Hey, do you still have the problem ?

I'm facing the exactly same issue : codegen show a success message but generate nothing

I'm running on Windows and the 2.0.2 prisma-binding

[EDIT] : I can put a crazy and non-existing path, I still get the same message

Code for project database generated to dldd:\testnotworking.ts

@NeutronScott12
Copy link

Nope, I still have the same issues, it's seem to be Windows having the issue, because it's working with Ubuntu, so it seems they need to do some testing for Window versions.

@divyenduz
Copy link
Contributor

Hi All,

We released a fix today that fixes the graphql codegen command on windows and makes it more robust overall.

Note that prisma deploy still won't run hooks on windows but running the graphql codegen command manually will work. We are working on that fix and it will be released soon.

Meanwhile, you can get the latest graphql-cli via npm install -g graphql-cli and check if the codegen files are generated for you.

Please let me know if that does not work.

@marktani
Copy link
Contributor Author

marktani commented Jun 8, 2018

Awesome thanks for all your feedback in this thread!

The general issue seems to be resolved by @divyenduz' recent work, so I'm closing this.

Please open a new issue if you are encountering further problems! 🙂

@marktani marktani closed this as completed Jun 8, 2018
@abelovic
Copy link

Is there another issue open for the hooks not running on windows? If not this should not be closed because it is only partially fixed. Those hooks should run otherwise it should be removed from the documentation (and updated with the intermediary fix) until there is a "complete" solution

@divyenduz
Copy link
Contributor

@abelovic : Hey, thanks for reaching out. This was resolved in prisma cli 1.9. Can you confirm your version by typing prisma --version and if needed install the latest via npm install -g prisma

Thanks!

@abelovic
Copy link

@divyenduz I didn't realize this fix was in prisma cli 1.9 ;P I just tried it out on the hooks seem to be running in windows correctly :) Thank you!

@ghost
Copy link

ghost commented Sep 20, 2018

I am still experiencing this issue on windows. I have the latest version 1.16.4 and with the changes suggested by Alvis

I get the confirmation that the processes were successful but nothing is actually created.
post-deploy: Running graphql get-schema --project database √ Running graphql codegen √

I also did graphql codegen separately with no effect.

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

No branches or pull requests