graphql-mesh web service 集成

前边有介绍过graphql-mesh 的基本使用,以下是一个集成web service 的简单学习

环境准备

  • 项目初始化
yarn  init -y
  • 添加依赖
yarn add graphql @graphql-mesh/runtime @graphql-mesh/cli   @graphql-mesh/soap soap
  • package.json
{
  "name": "second",
  "version": "1.0.0",
  "main": "index.js",
  "license": "MIT",
  "dependencies": {
    "@graphql-mesh/cli": "^0.0.16",
    "@graphql-mesh/runtime": "^0.0.16",
    "@graphql-mesh/soap": "^0.0.16",
    "graphql": "^14.6.0",
    "soap": "^0.31.0"
  },
  "scripts": {
    "start": "graphql-mesh serve"
  }
}

集成使用

  • .meshrc.yml 文件
sources:
  - name: CountryInfo
    handler:
      soap:
        wsdl: http://webservices.oorsprong.org/websamples.countryinfo/CountryInfoService.wso?WSDL
  • 启动
yarn start
  • 效果

地址 http://localhost:4000

  • 查询

说明

graphql-mesh 集成web service 简单高效,使用简单

参考资料

https://github.com/Urigo/graphql-mesh

原文地址:https://www.cnblogs.com/rongfengliang/p/12564029.html