Hi <@U38TMFV39> Run `prisma deploy`
# orm-help
k
Hi @kitze Run
prisma deploy
k
It doesn't generate it .. After my 2 deploys this morning I see that the
generated
folder hasn't changed for some reason
Since v1.7 the Prisma CLI doesn’t download
prisma.graphql
automatically any more, so you need to add this hook to get it
k
Ah the guide that I haven't finished reading yesterday
n
Let me know if you have more questions 🙌
k
Hmm after adding that hook
prisma.yml should NOT have additional properties. additionalProperty: endpoint
n
Which version of the Prisma CLI are you running (
prisma -v
)
k
1.8.3
n
hmm, maybe @nilan knows more about this?
m
Can you list your properties from that file? I had a similar problem when upgrading.
n
@kitze please check your local and global dep tree for the package
graphql-config-prisma-extension
and remove all old versions
k
Tnx @nilan that warning is gone, now the
generated
folder is empty
I ran yarn-upgrade interactive --latest, removed node_modules reinstalled them again
n
can you share your
prisma.yml
?
and
.graphqlconfig.yml
k
Copy code
endpoint: ${env:PRISMA_ENDPOINT}
secret: ${env:PRISMA_SECRET}
datamodel: datamodel.graphql

hooks:
  post-deploy:
    - echo "Deployment finished"
    - graphql get-schema --project db
    - graphql prepare
Copy code
projects:
  prisma:
    schemaPath: src/generated/prisma.graphql
    extensions:
      prisma: database/prisma.yml
      prepare-binding:
        output: src/generated/prisma.ts
        generator: prisma-ts
I get the
generated
folder but it's empty 🤔
graphql-cli
is not a local dependency of my project
should I add it?
I guess not because the result is the same, I just get an extra warning
warning command prepare both exists in plugin /Users/kitze/webdev/private/project/backend/node_modules/graphql-cli-prepare
I found the issue, @nikolasburk maybe you should change this line from
graphql get-schema --project db
to
graphql get-schema --project
it gets the schema from the current project without specifying the name (db)
I'll submit a PR
n
Ah in fact I think you can entirely remove the
--project
option then!
Thanks, please ping me with the link of the PR when it’s ready so I can merge it right away 🙂
Thanks for the help!
🦜 1
💯 1
ah one more issue @nikolasburk @nilan The newly generated .ts file is broken by default
c
Yeah, encountered it too, had to temporarily downgrade from prisma-bindings 2.0
k
@checkmatez to which version? is there an GH issue for this?
c
No, i wasn't able to find related issue. My current version is "prisma-binding": "1.5.19",
p
@nilan I thought that with 1.8.3 we shouldn’t be using
graphql prepare
anymore, am I wrong?
k
tnx @checkmatez, 1.5.19 fixes the TS errors
c
@kitze thank you too for hilarious tweets 🙂
k
😄
p
@kitze and thank you for sizzy.io 😉
n
@picosam that's not a question about your Prisma version, but rather a question about your GraphQL CLI workflow - happy to discuss this further in an issue here https://github.com/graphql-cli/graphql-cli
p
Yes of course, sorry. I just assumed that the latest version of
graphql-cli
was being used as well.
k
@picosam np 👊
n
yea I think with
codegen
you have much more flexibility now 🙂 but you can still use
prepare
(if
graphql
supports it)
p
@nilan just to clarify: with
codegen
one actually doesn’t need to put anything in the
yml
file anymore, correct?
n
well you still have to run the command - you can do so by adding a hook to
prisma.yml
. is that what you wanted to know?
s
p
Thank you @spacek33z, this is exactly what I’m referring to, and I’m really lost since a couple of days on this indeed.
@nilan I’m sorry to insist, but it’s still not clear. So even with
graphql-cli
2.16.0
and
prisma-binding
2.0.0
we’re still required to end up with a
prisma.ts
file that we can use with GraphQL Yoga (for example)?
From the Prisma 1.8 docs online (https://www.prisma.io/docs/tutorials/build-graphql-servers/development/build-a-graphql-server-for-an-existing-prisma-service-ohdaiyoo6c), I can’t seem to find the
codegen
command anywhere, and so I assumed that we simply do not run
prepare
(or anything else for that matter) anymore.
n
@tim2 can you chime in? 🙂
t
@picosam @spacek33z sorry for the confusion! We have new dedicated docs here that should help you: https://oss.prisma.io/content/GraphQL-Binding/03-Generator-CLI.html#usage-with-graphql-config
@picosam the new
codegen
basically just needs such a valid graphql config, no additional params to work
p
Thank you! I’m assuming:
Copy code
extensions:
codegen:
    - generator: prisma-binding
        language: typescript
        output:
          binding: prisma.ts
t
It still outputs a
prisma.ts
- a file containing the generated types
that looks correct!
😍 1
s
so is it correct that you no longer need two projects in the
.graphqlconfig.yml
? At the moment I have a "app" and a "prisma" project
p
@spacek33z why so? I think we still do!
s
I was thinking that because the example calls the project "myapp"
instead of, what I would expect, "prisma" or "db"
t
@spacek33z you probably still want both!
we should clarify that in the example
so what is shows is that you can call your projects like you want / have x number of projects in there
p
I belive these are the generic docs for
graphql-binding
, not specifically the
prisma-binding
. @tim2 if I may, I believe the confusion would be cleared if the docs at https://www.prisma.io/docs/tutorials/build-graphql-servers/development/build-a-graphql-server-for-an-existing-prisma-service-ohdaiyoo6c are amended instead.
t
Ok that's a good point @picosam! We will update that very soon!
So are all confusions out of the way for you @picosam @spacek33z?
👍 1
s
I'm trying out if it works right now, but the docs are still really confusing
t
that's a full running example showing how everything fits together
s
I saw that one, and it confuses me even more haha. It's
.graphqlconfig.yml
has this line
input: schema.js
where's that
schema.js
coming from suddenly
t
schema.js
means that you now can build your binding based on a
GraphQLSchema
instance exported by the
schema.js
we decided to do that because now you can first transform your schema ( https://www.apollographql.com/docs/graphql-tools/schema-transforms.html ) and then build a binding based on that
👍 1
p
…but it’s not required given the above simple configuration I pasted for
prisma-binding
if I understood correctly
t
correct!
but the above example at least requires a
schemaPath
that points to a correct schema.graphql file
👍 1
p
@spacek33z and that would be your
prisma.graphql
file generated using
graphql --getschema
so these two lines should be changed to only
graphql get-schema
?
t
they should be changed to
Copy code
- graphql get-schema
- graphql codegen
s
thanks, I'm one step further. the codegen command now complains about "Error: graphql-bindings 2.0 can only be generated based on an executable Schema exposed by a .js or .ts file" - I thought this
schema.js
file was not necessary?
t
Not necessary for
prisma-binding
- which is also what you should use here
that is basically the difference between the prisma-binding and graphq-binding - prisma-binding works with a remote endpoint, graphql-binding with an arbitrary local schema (wich can be a remote executable schema too)
s
I think it would all be clear if this example was updated: https://github.com/graphql-boilerplates/typescript-graphql-server/tree/master/advanced
this is the exact config I use too, and I think many others as well
t
yes we should definitely do that
s
yeah but that example has only one project in
.graphqlconfig.yml
, a different folder structure, uses a
schema.js
(which I don't want for now), etc.
t
ok true!
we'll soon fix the boilerplates
s
thanks! I'll try that
i
After applying all of the above changes, removing deps & installing again, changing Prisma versions, etc, I’m still stuck with the same console error 😕
I should specify… I am not getting any errors. Everything is logging to the console as if it’s working properly, and the deploy does, but the codegen does not
n
what happens when you run
graphql codegen
in your terminal?
i
I get an error that says that package wasn’t installed
I’m not actually sure what that package would be
p
graphql-cli
maybe?
i
That’s weird. I have that installed globally
m
Try installing it locally, too.
i
Shouldn’t make a difference. I’d have to run
./node_modules/.bin/graphql-cli
for that to work
n
looks like an npm issue 🙂
graphql-cli
is the right package.
i
But I do have it installed locally as well
So, I actually did just run
./node_modules/.bin/graphql-cli
and looked at my tree. It’s not installed
Not sure why it’s not installing or at least giving me an error that it didn’t install correctly. I’ll file an issue with them
m
I was having a similar issue and, while I agree it shouldn't make a diff, installing it locally magically made it work 🤷‍♂️
i
@nilan - Actually, I don’t think it’s a problem with NPM because I just tried installing globally with Yarn and that’s not working either
Ahh, finally got it
👍 1
But… Getting this again:
Copy code
warning command prepare both exists in plugin /Users/iamclaytonray/github.com/iamclaytonray/nest-prisma/node_modules/graphql-cli-prepare and is shipped with the graphql-cli.
The plugin is being ignored.
m
now remove it locally
i
And still no codegen
n
what is
graphql version
?both locally and globablly
i
2.16.0
Just uninstalled locally but was the same
m
Still getting the warning? That's odd.
i
So, after uninstalling locally, I don’t have the error anymore but still don’t have any codegen. I also don’t get any output from the console
Doesn’t even create a directory
n
please create a reproduction here: https://github.com/graphql-cli/graphql-cli please include your
.graphqlconfig.yml
and your
graphql version
.
m
Have you tried running
graphql codegen
from where ever your .graphqlconfig file is located?
i
Yep
No dice
m
Looks like it should be working and fails silently?
i
Looks that way
😕
m
Yeah. Frustrating. I feel you.
Let me ask one more weird question, do you have apollo-codegen installed globally as well?
i
Ermm
Let me check. I don’t think so
m
I'm just trying to think of any difference between our respective setups that could possibly be playing a role here
i
I do have it installed globally. Uninstalling now
Uninstalled but still no dice
Maybe I’m missing something super simple
m
I'll take a look because this is now driving me nuts too
i
Haha, thanks man!
m
ok, I think I see the issue.
Where you have this
Copy code
database:
    schemaPath: "src/generated/prisma.graphql"
    extensions:
      prisma: prisma.yml
      prepare-binding:
        output: src/generated/prisma.ts
        generator: prisma-binding
put this:
Copy code
codegen:
        generator: prisma-binding
        output:
          binding: src/generated/prisma.ts
        language: typescript
with proper indentation sorry about that
i
No dice 😕
m
Yeah. let me back up.
That was inarticulate.
So, with latest version, I don't think using
prepare-binding
as an extension is supported. I think we're supposed to use
codegen
in its place. Here is my yml:
Copy code
projects:
  prisma:
    schemaPath: src/generated/schema.graphql
    extensions:
      prisma: database/prisma.yml
      codegen:
        generator: prisma-binding
        output:
          binding: src/generated/prisma.js
        language: javascript
i
Hmmm
Well this is interesting:
Copy code
⠋ Generating bindings for project database...{ Error: ENOENT: no such file or directory, open '/Users/iamclaytonray/github.com/iamclaytonray/nest-prisma/src/generated/prisma.graphql'
    at Object.fs.openSync (fs.js:660:18)
    at Object.fs.readFileSync (fs.js:565:33)
    at getSchemaFromInput (/Users/iamclaytonray/github.com/iamclaytonray/nest-prisma/node_modules/prisma-binding/dist/bin.js:104:41)
    at /Users/iamclaytonray/github.com/iamclaytonray/nest-prisma/node_modules/prisma-binding/dist/bin.js:78:22
    at step (/Users/iamclaytonray/github.com/iamclaytonray/nest-prisma/node_modules/prisma-binding/dist/bin.js:33:23)
    at Object.next (/Users/iamclaytonray/github.com/iamclaytonray/nest-prisma/node_modules/prisma-binding/dist/bin.js:14:53)
    at /Users/iamclaytonray/github.com/iamclaytonray/nest-prisma/node_modules/prisma-binding/dist/bin.js:8:71
    at new Promise (<anonymous>)
    at __awaiter (/Users/iamclaytonray/github.com/iamclaytonray/nest-prisma/node_modules/prisma-binding/dist/bin.js:4:12)
    at run (/Users/iamclaytonray/github.com/iamclaytonray/nest-prisma/node_modules/prisma-binding/dist/bin.js:74:12)
  errno: -2,
  code: 'ENOENT',
  syscall: 'open',
  path: '/Users/iamclaytonray/github.com/iamclaytonray/nest-prisma/src/generated/prisma.graphql' }

✔ Code for project database generated to src/generated/prisma.ts
I did create those files and run again but it gave me the same output as above
m
Sorry for whatever reason my internet went down. One sec ...
i
No big deal. Trying to fix an issue with codegen in Go too, haha
😭 1
m
in prisma.yml replace
- graphql prepare
with
- graphql codegen
i
Haha:
Copy code
⠋ Generating bindings for project database...{ GraphQLError: Syntax Error: Unexpected <EOF>
    at syntaxError (/Users/iamclaytonray/github.com/iamclaytonray/nest-prisma/node_modules/graphql/error/syntaxError.js:24:10)
    at unexpected (/Users/iamclaytonray/github.com/iamclaytonray/nest-prisma/node_modules/graphql/language/parser.js:1322:33)
    at parseDefinition (/Users/iamclaytonray/github.com/iamclaytonray/nest-prisma/node_modules/graphql/language/parser.js:152:9)
    at parseDocument (/Users/iamclaytonray/github.com/iamclaytonray/nest-prisma/node_modules/graphql/language/parser.js:110:22)
    at parse (/Users/iamclaytonray/github.com/iamclaytonray/nest-prisma/node_modules/graphql/language/parser.js:38:10)
    at Object.buildSchema (/Users/iamclaytonray/github.com/iamclaytonray/nest-prisma/node_modules/graphql/utilities/buildASTSchema.js:447:43)
    at getSchemaFromInput (/Users/iamclaytonray/github.com/iamclaytonray/nest-prisma/node_modules/prisma-binding/dist/bin.js:104:26)
    at /Users/iamclaytonray/github.com/iamclaytonray/nest-prisma/node_modules/prisma-binding/dist/bin.js:78:22
    at step (/Users/iamclaytonray/github.com/iamclaytonray/nest-prisma/node_modules/prisma-binding/dist/bin.js:33:23)
    at Object.next (/Users/iamclaytonray/github.com/iamclaytonray/nest-prisma/node_modules/prisma-binding/dist/bin.js:14:53)
  message: 'Syntax Error: Unexpected <EOF>',
  locations: [ { line: 1, column: 1 } ],
  path: undefined }

✔ Code for project database generated to src/generated/prisma.ts
m
Ok, I think I got it.
graphqlconfig:
Copy code
projects:
  prisma:
    schemaPath: src/generated/schema.graphql
    extensions:
      prisma: prisma.yml
      codegen:
        generator: prisma-binding
        output:
          binding: src/generated/prisma.ts
        language: typescript
that should be the entirety of your
.graphqlconfig.yml
file
i
Nope
m
Cray. Because I just cloned your repo and made those changes and it works like a charm here.
i
Huh
And you are just running
graphql codegen
In the root of the project
m
prisma deploy
i
That did it
m
WOOO!
i
Haha, thanks for all of your help man!
m
No prob. I can empathize--was basically in the same position as you about a week and a half ago before prisma-binding 2.0 was released and these guys (@nilan and @schickling) did the same for me--so paying it forward 🙂
i
🙂
s
thanks @medelman, that did the trick for me as well. This was the diff for me, maybe it helps anyone: https://github.com/Volst/foed/commit/54b41651782d502a95f29317022574f26e1356b4
i
@spacek33z - Do you mind if I add that to the issue I created (and closed) so others may see it?
s
Sure!
p
OMG I wish I saw all this, just came back from a meeting. Yes, that’s precisely what had done it for me 5 hours ago, I’m sorry I didn’t write it clearly here 😞
It seems you’ve been talking for a while here. I’m glad we’re all through with this one now; still hoping for my yarn workspaces issue lol
i
Haha
m
what do they say, something like 'it's not about the journey, it's about where you end up.'
🙂
p
I hope you meant to say that the other way around
👍 1
m
Guess it depends on if you're in a good spot at the moment or not hahaha
😂 2
n
thanks so much everyone for your help and paying it forward 🙂 I've been taking notes for improvements to the docs and boilerplates so this is less likely to happen again!
💚 2