prisma / prisma1

💾 Database Tools incl. ORM, Migrations and Admin UI (Postgres, MySQL & MongoDB) [deprecated]
https://v1.prisma.io/docs/
Apache License 2.0
16.54k stars 861 forks source link

prisma server side subscriptions deploy error #2967

Closed rongfengliang closed 6 years ago

rongfengliang commented 6 years ago

prisma server side subscriptions deploy error when i use the service side subscriptions for test ,but i get some error

Errors:

Subscription ✖ The provided query doesn't include any known model name. Please check for the latest subscriptions API.

this is my config

datamodel.graphql

type User {
  id: ID! @unique
  name: String!
  age: Int
}

prisma.yml

endpoint: http://localhost:4466
datamodel: datamodel.graphql
subscriptions:
  welcomeNewUser:
    webhook: http://mock:8080/webhook
    query: subscription.graphql

subscription.graphql

subscription {
  user(where:
    {
      mutation_in:CREATED
    }){
    node {
      id
      name
      age
    }
  }
}

docker-compose.yaml

version: '3'
services:
  prisma:
    image: prismagraphql/prisma:1.14
    ports:
    - "4466:4466"
    environment:
      PRISMA_CONFIG: |
        port: 4466
        # uncomment the next line and provide the env var PRISMA_MANAGEMENT_API_SECRET=my-secret to activate cluster security
        # managementApiSecret: my-secret
        databases:
          default:
            connector: mysql
            host: mysql
            port: 3306
            user: root
            password: prisma
            migrations: true
  mysql:
    image: mysql:5.7
    ports:
    - "3306:3306"
    environment:
      MYSQL_ROOT_PASSWORD: prisma
    volumes:
      - ./data/mysql:/var/lib/mysql
  mock:
    image: rodolpheche/wiremock
    ports:
      - "9089:8080"
    command: "--local-response-templating --verbose"
    volumes:
      - ./stubs:/home/wiremock/mappings

wiremock mock json file

{
    "request": {
      "method": "POST",
      "url": "/webhook"
    },
    "response": {
      "status": 200,
       "body":"{{{request.body}}}",
       "headers": {
        "TOKEN": "{{request.headers.TOKEN}}",
        "URL":"{{request.url}}",
        "content-type":"application/json"
      },
      "transformers": ["response-template"]
    }
}

when i start the docker-compose service running is ok

      Name                     Command               State                 Ports
----------------------------------------------------------------------------------------------
database_mock_1     /docker-entrypoint.sh --lo ...   Up      0.0.0.0:9089->8080/tcp, 8443/tcp
database_mysql_1    docker-entrypoint.sh mysqld      Up      0.0.0.0:3306->3306/tcp, 33060/tcp
database_prisma_1   /bin/sh -c /app/start.sh         Up      0.0.0.0:4466->4466/tcp
rongfengliang commented 6 years ago

i found some thing

first time i use prisma deploy with server side subscriptions config is throw errors

but if i comment the server side subscriptions just like this

endpoint: http://localhost:4466
datamodel: datamodel.graphql
# subscriptions:
#   welcomeNewUser:
#     webhook: http://mock:8080/webhook
#     query: subscription.graphql

and prisma deploy it ok but server side subscriptions not work (certainly)

then i uncomment the server side subscriptions config

endpoint: http://localhost:4466
datamodel: datamodel.graphql
subscriptions:
  welcomeNewUser:
    webhook: http://mock:8080/webhook
    query: subscription.graphql

i use prisma deploy --force it works

some data from mysql

# projectId, revision, schema, functions, status, applied, rolledBack, steps, errors, startedAt, finishedAt
'default@default', '3', '{\"models\":[{\"name\":\"User\",\"stableIdentifier\":\"cjld7i4ew00040a509xlp1x2f\",\"fields\":[{\"name\":\"id\",\"typeIdentifier\":\"GraphQLID\",\"isRequired\":true,\"isList\":false,\"isUnique\":true,\"isHidden\":false,\"isReadonly\":false,\"isAutoGenerated\":false},{\"name\":\"name\",\"typeIdentifier\":\"String\",\"isRequired\":true,\"isList\":false,\"isUnique\":false,\"isHidden\":false,\"isReadonly\":false,\"isAutoGenerated\":false},{\"name\":\"age\",\"typeIdentifier\":\"Int\",\"isRequired\":false,\"isList\":false,\"isUnique\":false,\"isHidden\":false,\"isReadonly\":false,\"isAutoGenerated\":false},{\"name\":\"version\",\"typeIdentifier\":\"String\",\"isRequired\":true,\"isList\":false,\"isUnique\":false,\"isHidden\":false,\"isReadonly\":false,\"isAutoGenerated\":false},{\"name\":\"updatedAt\",\"typeIdentifier\":\"DateTime\",\"isRequired\":true,\"isList\":false,\"isUnique\":false,\"isHidden\":true,\"isReadonly\":true,\"isAutoGenerated\":false},{\"name\":\"createdAt\",\"typeIdentifier\":\"DateTime\",\"isRequired\":true,\"isList\":false,\"isUnique\":false,\"isHidden\":true,\"isReadonly\":true,\"isAutoGenerated\":false}]}],\"relations\":[],\"enums\":[]}', '[{\"name\":\"welcomeNewUser\",\"isActive\":true,\"delivery\":{\"url\":\"http://mock:8080/webhook\",\"headers\":[],\"type\":\"webhook-delivery\"},\"query\":\"subscription {\\n  user(where:\\n    {\\n      mutation_in:CREATED\\n    }){\\n    node {\\n      id\\n      name\\n      age\\n    }\\n  }\\n}\",\"type\":\"server-side-subscription\"}]', 'SUCCESS', '0', '0', '[]', '[]', '2018-08-28 04:23:47', '2018-08-28 04:23:47'

and then i call creteuser mutation

mutation {

  createUser(data:{
    name:"appdemo",
    age:444,
    version:"v1"
  }){
    id
    name
    age
    version
  }
}

the wiremock log message

wx20180828-122643 2x

maybe with some wrong for deploy with config server side subscriptions

marktani commented 6 years ago

Thanks for reporting this! This seems to be a duplicate of #2064, which was fixed in 1.15.3. You have not specified the version you're using, so I assume you're on an older version. Please upgrade 🙂