Hi I'm trying to get the go graphql example runnin...
# orm-help
s
Hi I'm trying to get the go graphql example running on my Mac. When I send a query to http://localhost:4000 I get:
Copy code
{
  "data": null,
  "errors": [
    {
      "message": "Post : unsupported protocol scheme \"\"",
      "path": [
        "feed"
      ]
    }
  ]
}
Any ideas?
n
Are you using Golang?
Which example are you using exactly?
s
The go graphql example
n
Looking into it now πŸ™‚
s
Great. Thank you!
n
Could you post your terminal output after
prisma deploy
if you still have it? It should look similar to this:
Copy code
$ prisma deploy
Creating stage dev for service prisma βœ”
Deploying service `prisma` to stage `dev` to server `prisma-eu1` 147ms

Changes:

  User (Type)
  + Created type `User`
  + Created field `id` of type `ID!`
  + Created field `email` of type `String!`
  + Created field `name` of type `String`
  + Created field `posts` of type `[Post!]!`
  + Created field `updatedAt` of type `DateTime!`
  + Created field `createdAt` of type `DateTime!`

  Post (Type)
  + Created type `Post`
  + Created field `id` of type `ID!`
  + Created field `createdAt` of type `DateTime!`
  + Created field `updatedAt` of type `DateTime!`
  + Created field `published` of type `Boolean!`
  + Created field `title` of type `String!`
  + Created field `content` of type `String`
  + Created field `author` of type `User!`

  PostToUser (Relation)
  + Created relation between Post and Post

Applying changes 1.3s

Hooks:
Seeding based on seed.graphql 19.6s

Your Prisma GraphQL database endpoint is live:

  HTTP:  <https://eu1.prisma.sh/nikolas/prisma/dev>
  WS:    <wss://eu1.prisma.sh/nikolas/prisma/dev>


post-deploy:

Generating schema... 21ms

Running prisma generate...
Saving Prisma Client (Go) at /Users/nikolasburk/go/src/github.com/prisma/prisma-examples/go/graphql/prisma-client/
Running prisma generate βœ”
Also, please check whether the
var DefaultEndpoint
is set in
prisma.go
I suspect that your client (i.e. the code in
prisma.go
) might not have been generated after
prisma deploy
for some reason. That's why
DefaultEndpoint
might be empty which leads to that error.
s
I'll start again from scratch. I don't have that output.
n
What did you see instead?
s
I mean that I ran deploy a few days ago
So I don't know what the output was
πŸ‘ 1
OK so the first problem I've got it when I select demo server and click "grant permission" in the browser I get the error "Network error: Unexpected token < in JSON at position 0"
I gave up on this last time and tried the local docker option
n
Ah got it! Yeah it should work locally as well.
s
Yes
n
Ok, thanks! I'm reporting it to the team that we still have this problem! πŸ™Œ
Let's try to make your local setup work!
s
OK
n
If you'r starting from scratch, then you need to create this Docker Compose file:
Copy code
version: '3'
services:
  prisma:
    image: prismagraphql/prisma:1.23
    restart: always
    ports:
    - "4466:4466"
    environment:
      PRISMA_CONFIG: |
        port: 4466
        databases:
          default:
            connector: mysql
            host: mysql
            port: 3306
            user: root
            password: prisma
            migrations: true
  mysql:
    image: mysql:5.7
    restart: always
    environment:
      MYSQL_ROOT_PASSWORD: prisma
    volumes:
      - mysql:/var/lib/mysql
volumes:
  mysql:
Then run
docker-compose up -d
to launch the local Prisma server and the database.
Let me know when you have that πŸ™‚
s
Yep. docker-compose has finished
n
Great, can you quickly run
docker ps
and paste the output here please.
s
Copy code
CONTAINER ID        IMAGE                       COMMAND                  CREATED             STATUS              PORTS                    NAMES
8af558805885        prismagraphql/prisma:1.23   "/bin/sh -c /app/sta…"   44 seconds ago      Up 42 seconds       0.0.0.0:4466->4466/tcp   graphql_prisma_1
2877f9c4e4ab        mysql:5.7                   "docker-entrypoint.s…"   44 seconds ago      Up 42 seconds       3306/tcp, 33060/tcp      graphql_mysql_1
n
Looks good πŸ‘
Now you have the downloaded the
go/graphql
example right? Can you navigate into that and then run
prisma deploy
again.
s
Yep
Create new database?
n
Ah, it shows an interactive prompt?
s
Yeah
n
Sorry, please abort with ctrl+c
s
OK
n
Then add
<http://localhost:4466/>
as the
endpoint
in prisma.yml
Then run
prisma deploy
again
s
I don't see a prisma.yml file in
prisma-examples/go/graphql
n
should be inside the
graphql/prisma
s
Ah
Done
n
Now you should be able to continue with step 4 from the README: https://github.com/prisma/prisma-examples/tree/master/go/graphql#4-start-the-graphql-server πŸ™Œ
Does it work this time?
s
Sorry same problem
n
Ok, can you please check if
DefaultEndpoint
in
prisma.go
is set?
Did you see this at the end of the
prisma deploy
command output?
Copy code
post-deploy:

Generating schema... 21ms

Running prisma generate...
Saving Prisma Client (Go) at /Users/nikolasburk/go/src/github.com/prisma/prisma-examples/go/graphql/prisma-client/
Running prisma generate βœ”
s
You asked me to cancel prisma deploy
n
Ah sorry, after setting the
endpoint
in
prisma.yml
I asked you to rerun
prisma deploy
s
πŸ™ˆ
Yeah i get that output
n
Ok, then try continuing with the README steps now πŸ˜„
s
DefaultEndpoint is now set in prisma.go, but I have the same problem when sending a query
n
Hmm
I'm afraid this is where my remote debugging skills can't help any further and I need to ask you to create a GitHub issue for that 😞 https://github.com/prisma/prisma/issues/new?template=bug_report.md
s
OK that's fine. Thanks for your help.
n
My alternative recommendation is to follow the Getting Started tutorial in the docs: https://www.prisma.io/docs/1.23/get-started/01-setting-up-prisma-new-database-GO-g002/
This sets up everything from scratch, maybe that works better for you!
s
I'll give it a try. Thanks.
I've made progress of sorts
I just found this command:
Copy code
prisma init --endpoint <http://localhost:4466>
Then I ran
prisma deploy --force
Now I can send queries to http://localhost:4466
But I have a totally different API schema to play with
I think
Maybe it's the same schema - posts, authors, feeds etc
n
The GraphQL API that's running on port
4466
is not the one exposed by the Go GraphQL server - it's the underlying Prisma API that gets consumed by the Prisma Go client in the GraphQL resolvers.
It looks similar (especially because the models are very similar) but you'll see that the actual queries and mutations are not the same.
The Prisma API on port
4466
exposes full CRUD operations while your Go GraphQL server exposes only those operations defined in
schema.graphql
s
Ah. Thanks for the explanation.