Hello, I need help! We have deployed a Prisma app ...
# prisma-whats-new
r
Hello, I need help! We have deployed a Prisma app on production, running on Digital Ocean. I need to update some data base records. On my local, I can access the DB schema which shows on the left hand side below the App schema. How do I access the same thing for the prisma service deployed on DO
βœ… 1
s
Hi Rohan - happy to help πŸ™‚
I assume you have deployed both a graphql-yoga based server as well as Prisma. Are they both running on the same DO instance?
You will have to connect to the port that Prisma is running on. The Prisma CLI should tell you the correct url to use. If you have set a secret for the service you will have to supply an Authorization header in the playground. You can generate a token using the prisma cli:
prisma token
and then construct the header like this:
{"Authorization": "paste the token"}
r
Hi @sorenbs Thanks for the reply!
I'll give you a brief overview of our current deploymeny
We have deployed Prisma on a DO server using manual Docker deployment since there were issues related to docker-compose clsuter deployment
I can access the app schema at <ip>:4000
The issue is when I try to access the playground at <ip>:3000 from my local machine... I can see the app schema ... but for database schema, it's trying to connect to localhost:4466 ... which times out on my machine
@sorenbs I'm sorry I just dropped a screenshot as a DM
s
Oh, I see. Can you try to manually change that from localhost to the correct IP? You should be able to do it directly in the Playground, but otherwise simply open that URL in a new browser tab
It looks like your graphqlconfig file is using the wrong environment variables on the server, so it uses
localhost
instead of the correct ip
r
@sorenbs sorry for the late response... was travelling to work
sending you
graphqlconfig
which is on the DO server
it does have localhost
Copy code
projects:
  app:
    schemaPath: "src/schema.graphql"
    extensions:
      endpoints:
        default: "<http://localhost:4000>"
  database:
    schemaPath: "src/generated/prisma.graphql"
    extensions:
      prisma: database/prisma.yml
      prepare-binding:
        output: src/generated/prisma.ts
        generator: prisma-ts
I'm not able to change localhost to IP in playground (plz refer to the screenshot which I DM you)... that field is disabled
I changed my graphqlconfig to :
Copy code
projects:
  app:
    schemaPath: "src/schema.graphql"
    extensions:
      endpoints:
        default: "<http://139.59.80.18:4000>"
  database:
    schemaPath: "src/generated/prisma.graphql"
    extensions:
      prisma: database/prisma.yml
      prepare-binding:
        output: src/generated/prisma.ts
        generator: prisma-ts
@sorenbs Thanks! I opened a new tab with
http://<IP>:4466/cric-prisma/prod
as per your suggestion and it works πŸ™‚
I can use this as a workaround now for modifying my production DB
Just wanted to know if I'm missing something here :
How can I get the actual IP address in the playground URL rather than
Copy code
localhost:4466
Thank you very much @sorenbs for quick help at such an odd hour πŸ™‚ I would love to share our production app URL, although I'm a bit skeptical as to if I have left any loopholes open since I'm very new to graph.cool & Prisma; some might try to screw our app
Our client is a Charity in India. We built an app for them to conduct a national level cricket league using Prisma in like 8 days πŸ™„
fast parrot 1
a
Does your
prisma.yml
point to the correct cluster on your local machine?
Because the playground determines the URL for the prisma endpoint from the cluster setting in
prisma.yml
s
That’s great to hear @rohanray! Best of luck πŸ™‚
r
Thanks @sorenbs we have been working our ass off since a few days to get this delivered... looks like it wouldn't have been possible w/o prisma πŸ™‚ reduced our dev time a lottttt
πŸ’― 1
@agartha Thanks for pitching in! I was trying to access the playground directly available at
<DO_IP>:3000/playground
from my local machine. Not sure if my local
prisma.yml
will affect that
Please do let me know if understanding is incorrect
a
Yes, it does. The playground runs on localhost:3000/playground, but each endpoint you see on the left has its own endpoint address (that you see in the playground address bar when you select it).
For 'normal' endpoints, this endpoint is specified in the
.graphqlconfig
file
r
@agartha Also lets say if I want to connect to prisma DB service (i.e. database schema) of my DO prisma cluster from desktop playground app installed on my mac... how would I go about it? Please can u give someinputs on that
a
But for prisma endpoints, you'll notice there is no endpoint in your
.graphqlconfig
file
What is the cluster that is specified in your prisma.yml file?
r
do u mean the prisma.yml on DO server?
a
On the machine where you open the playground
So in your case, I think the DO server yes
r
Copy code
NODE_ENV="production"
PRISMA_STAGE="prod"
PRISMA_ENDPOINT="<http://1xx.xx.xx:4466/cric-prisma/prod>"
PRISMA_CLUSTER="local"
PRISMA_SECRET="xxx"
APP_SECRET="xxx"
S3_BUCKET="jpl-cric"
S3_KEY="xxx"
S3_SECRET="xxx"
dats the
.env
file on DO
a
Okay, so cluster = local
Now, there is also a ~/.graphcoolrc file on that machine
r
Copy code
service: cric-prisma

# the cluster and stage the service is deployed to
stage: ${env:PRISMA_STAGE}

# to disable authentication:
# disableAuth: true
secret: ${env:PRISMA_SECRET}

# the file path pointing to your data model
datamodel:
  - datamodel/types.graphql
  - datamodel/enums.graphql

# seed your service with initial data
#seed:
 # import: seed.graphql

cluster: ${env:PRISMA_CLUSTER}

#START CUSTOM RORAY

# Path where the full GraphQL schema will be written to
# after deploying. Note that it is generated based on your
# data model.
a
That contains a key for that cluster name (local) with an address
That's the address the playground uses
r
Copy code
projects:
  app:
    schemaPath: "src/schema.graphql"
    extensions:
      endpoints:
        default: "<http://localhost:4000>"
  database:
    schemaPath: "src/generated/prisma.graphql"
    extensions:
      prisma: database/prisma.yml
      prepare-binding:
        output: src/generated/prisma.ts
        generator: prisma-tsprojects:
  app:
    schemaPath: "src/schema.graphql"
    extensions:
      endpoints:
        default: "<http://localhost:4000>"
  database:
    schemaPath: "src/generated/prisma.graphql"
    extensions:
      prisma: database/prisma.yml
      prepare-binding:
        output: src/generated/prisma.ts
        generator: prisma-ts
☝️ is
graphcoolrc
file on DO server
a
No, that's .graphqlconfig
~/.graphcoolrc
looks something like this:
Copy code
graphcool-1.0:
  cloudSessionKey: >-
    eyJhb...
  clusters:
    local:
      host: '<http://localhost:60000>'
      clusterSecret: "-----BEGIN RSA PRIVATE KEY-----\r\nMIIEo....
r
Apologies!
I dont see any
.graphcoolrc
file at
~
i do have
~/prisma/config.yml
looks like below
Copy code
clusters:
  local:
    host: '<http://localhost:4466>'
    clusterSecret: "-----BEGIN RSA PRIVATE KEY-----\r\nMIIEogIBAAKCAQEAncTGcWRLFPsm6zQu+ND3CwQSAg45eIJ23UL1w5srCXVTrJmr\r\nMFfV5YERP0sdxCfryksl2ZWetZgndEsvKW5MOX5qPuDaGx8kIzyvZDci8nLwVyUj\r\nUHbYmRkTFFdDIRqwQSt/3yxiHTeh9l0KTiFH69TsZEoYJnCaEjfOGhm9cqivLuwS\r\nxJL8hVwzx4ntIxSAw7zmmD+o9xfNEx+21eyyajFJshkjELea .....
a
Oops, new location... Sorry...
Yes that one
Now that
host
you see in there is the one the playground uses
So if you change that to your external IP instead of internal
r
ahh I see
a
Then the playground will be able to access the prisma endpoint
r
Is it only used by playground or also by
graphql-yoga
server... or
graphql-yoga
server uses
database/prisma.yml
file for prisma endpoint lcoation
a
No it's not used by graphql-yoga
That uses the env var PRISMA_ENDPOINT you specified
So it goes from: 1. project in .graphqlconfig 2. prisma extension in .graphqlconfig points to prisma.yml 3. prisma.yml contains a cluster name 4. ~/.prisma/config.yml contains host for cluster 5. playground uses that host
Also,
prisma deploy
uses that host to deploy to your cluster
r
I see... that is golden information for prisma users πŸ™‚ I'm very new to prisma... plz forgive my noobness
a
The
graphql-yoga
server uses whatever you have specified on your binding in the index.js or .ts file
Well, not many ppl run on their own cluster server yet, so most of the docs are focussed on running locally on or the public clusters
r
@agartha Thanks very much... changed the endpoint in ~/.prisma/config.yml to point to external IP instead of localhost and it works πŸ˜„
fast parrot 1
a
@sorenbs I think the thread above might contain some pointers for improving the docs ^^
r
yes I know... I took a very bold step of selecting prisma to deliver the app the next day after prisma was announced πŸ˜› My life is kinda hanging on it now for a month... the tournament ends on 24-Feb
@agartha Can't thank you much... super helpful
a
@rohanray Now I'm almost 100% sure that this won't affect the
prisma deploy
, as I assume the cluster is reachable on its external IP while deploying as well, but make sure to test that.
r
oh yeah ... let me try that
a
As long as it says: 'Already up to date' and no error, I think you're gtg
r
this is my workflow of pushing DB schema changes to DO server for now... ssh to DO .. git pull...
prisma deploy
I
a
You should be able to just copy that cluster info from
~/.prisma/config.yml
to your local machine and deploy directly from your own machine
r
it works @agartha Thank you very very much ! πŸ™‚ super glad for helping me out
πŸ™πŸ» 1
a
Especially with the external IP in there
r
yep
indeed
a
So that's another benefit
r
you are right... thanks!
fast parrot 1
Just wanted to know how tightly is prisma integrated to docker
For production .. I wanted to deploy Mysql docker on another VM whose data volume would be an external volume storage
Then I wanted to connect that Mysql service to prisma docker service
a
I'm going to leave answering that question up to the graphcool guys.
r
oh sure... Thanks a lot @agartha much appreciated
a
But in theory, the docker config for prisma just needs the right connection string
r
der were some issues in re docker-compose deployment... I will look into it again once I have some free time
a
So if you leave the db container out, and set the variables in the dockerfile to the right server and port, that should work
But I guess you'll definitely be in uncharted territory doing that...
r
cool... will probably try that today some time...
correct πŸ™‚ right now I'm happy with the prisma local cluster stand-alone installation on DO ... can't touch that installation anymore now as we are live
we consume the graphql yoga service running on 4000 thru a nginx proxy
all other ports of that DO machine are disabled thru F/W
a
okay
Well, it seems like you've got it all covered for now. I'm off now (it's 6:30 am here...)
r
whenever I need to access DB schema running on 4466 ... I just enable port 4466... do my work... switch it off back in F/W again... hope there can be some better workflow for this
so sorry @agartha I got carried away
please get some rest ... cheers!
a
No problem. In theory, your backend endpoint is protected by a token, so you might just as well leave that port open
But for extra security, I think what you're doing is the right thing
r
true!
a
Maybe DO offers some scripting or something to open/close ports
So you can have a deploy script locally that opens the port, runs the deploy, and closes it again
r
yes... since I dont wanna risk undiscovered security issues screwing my app
DO offers a nice GUI for F/W's πŸ˜‰
web console i mean
a
Makes perfect sense. Normally, the graphql-yoga server hides the endpoint address for clients, but as you run it on the same server, just disabling outside access is the best security you can get
Good thinking
Okay, I'm off, glad thing worked out, and I'm sure graphcool will pick up on the documentation for this soon
r
sure... dont want to keep u awake anymore πŸ™‚ g'nite! Thanks a ton
m
@agartha You might consider a blog post on the config file-locations, sounds like you know your stuff πŸ™‚
πŸ‘ 2