zoukankan      html  css  js  c++  java
  • prisma graphql 工具基本使用

    项目使用docker-compose mysql 运行

    安装

    npm insatll -g prisma
    or 
    yarn global add prisma

    创建代码

    • 项目结构
    ├── README.md
    ├── datamodel.graphql
    ├── docker-compose.yml
    └── prisma.yml
    • prisma.yml
    endpoint: http://localhost:4466
    datamodel: datamodel.graphql
    • datamodel
    type User{
      id: ID! @unique
      name: String!
      age:Int
      appinfo:String
      appinfodemo:String
      version:Int
    }
    
    type Person{
        id: ID! @unique
        pername:String
        age:Int
    }
    type AppURL {
        id: ID! @unique
        appname:String
        appurl:String
    }
    type Tweet {
      id: ID! @unique
      createdAt: DateTime!
      text: String!
      owner: User!
    }
    
    type UserTweet {
      id: ID! @unique
      handle: String! @unique
      name: String!
      tweets: [Tweet!]!
    }

    docker-compose

    version: '3'
    services:
      prisma:
        image: prismagraphql/prisma:1.8
        restart: always
        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
        restart: always
        environment:
          MYSQL_ROOT_PASSWORD: prisma
        volumes:
          - mysql:/var/lib/mysql
        ports:
          - "3306:3306"
    volumes:
      mysql:

    运行

    • 启动docker-compose
    docker-compose up -d
    • 访问


    参考资料

    https://github.com/rongfengliang/prisma-demo
    https://www.prisma.io/

  • 相关阅读:
    iOS--异步下载
    linux搭建ftp服务器
    hexo常用命令
    Markdown入门
    Markdown 语法和 MWeb 写作使用说明
    vi/vim
    微信聊天机器人
    .vimrc
    配置双机
    python学习笔记(一)
  • 原文地址:https://www.cnblogs.com/rongfengliang/p/9265992.html
Copyright © 2011-2022 走看看