• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

teamwalnut/graphql-ppx: GraphQL language primitives for ReScript/ReasonML writte ...

原作者: [db:作者] 来自: 网络 收藏 邀请

开源软件名称(OpenSource Name):

teamwalnut/graphql-ppx

开源软件地址(OpenSource Url):

https://github.com/teamwalnut/graphql-ppx

开源编程语言(OpenSource Language):

OCaml 93.5%

开源软件介绍(OpenSource Introduction):

Logo

Typesafe GraphQL operations and fragments in ReasonML

Build Status npm version

DocumentationFeaturesInstallationUsageRoadmapContributingLicenseAcknowledgements

Documentation

Go to the official documentation

Features

  • Language level GraphQL primitives

  • Building block for GraphQL clients

  • 100% type safe

Installation

Schema

graphql-ppx needs your graphql schema to be available in the form of a graphql_schema.json file.

The easiest way to add this to your project is using an introspection query to your backend. You can do this using get-graphql-schema:

npx get-graphql-schema ENDPOINT_URL -j > graphql_schema.json

With ENDPOINT_URL being the URL of your GraphQL endpoint.

Cache

graphql-ppx will generate a .graphql_ppx_cache folder alongside your JSON schema to optimize parsing performance. If you're using a version control system, you don't need to check it in.

The next pages will provide further installation instructions whether you are using graphql-ppx with Bucklescript or using Reason Native.

Bucklescript

First, add it to you dependencies using npm or yarn:

yarn add @reasonml-community/graphql-ppx --dev
# or
npm install @reasonml-community/graphql-ppx  --saveDev

Second, add it to ppx-flags and bs-dependencies in your bsconfig.json:

"ppx-flags": ["@reasonml-community/graphql-ppx/ppx"],
"bs-dependencies": ["@reasonml-community/graphql-ppx"]

Native

Caution!

The Bucklescript version of graphql-ppx was almost completely rewritten for the 1.0 release, with many improvements and changes. This documentation will focus on the API of the bucklescript version. This means that most of the examples won't apply for the Reason Native version. Please take a look at the old documentation. At the same time we welcome contributions to modernize the Reason Native version of graphql-ppx :::

You need to provide the following dependency in your esy.json file

{
  "dependencies": {
    "graphql-ppx": "*"
  },
  "resolutions": {
    "graphql-ppx": "reasonml-community/graphql-ppx:esy.json#<use latest stable commit from master>"
  }
}

and update your dune file:

(preprocess (pps graphql_ppx))

Usage

Make your first query:

Reason

[%graphql {|
  query UserQuery {
    user {
      id
      name
    }
  }
|}];

ReScript

%graphql(`
  query UserQuery {
    user {
      id
      name
    }
  }
`)

Open getting started in the docs

Roadmap

See our development board for a list of selected features and issues.

Contributing

We'd love your help improving graphql-ppx!

Take a look at our Contributing Guide to get started.

License

Distributed under the MIT License. See LICENSE for more information.

Acknowledgements

Thanks to everyone who contributed to graphql-ppx!

This project builds upon mhallin/graphql_ppx. It wouldn't be possible without great work of mhallin/graphql_ppx contributors. 1




鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap