anwoon/blueprint-graphql-addon

该软件包最新版本(1.0.4)没有可用的许可证信息。

用于生成针对lighthouse或其他库的graphql类型文件的blueprint插件

1.0.4 2022-08-31 12:52 UTC

This package is auto-updated.

Last update: 2024-09-29 06:14:54 UTC


README

安装

composer require --dev anwoon/blueprint-graphql-addon

你需要在你的 filesystem disk 中添加以下内容

'graphql' => [
    'driver' => 'local',
    'root' => 'graphql',
    'throw' => false,
],

使用

参考 Blueprint的基本用法 以开始使用。之后,你可以运行 blueprint:build 命令来自动生成Graphql资源。为了了解其易用性,你可以使用下面的示例 draft.yaml 文件。

models:
  Post:
    title: string:400
    content: longtext
    total: decimal:8,2
    status: enum:pending,successful,failed
    published_at: timestamp nullable
    author_id: id foreign:users
    relationships:
      hasMany: Comment
      belongsToMany: Site
      belongsTo: User
type Post implements Model {
    id: ID!
    title: String!
    content: String!
    total: String!
    status: Status!
    published_at: Timestamp
    author_id: ID!
    comments: [Comment!] @hasMany
    sites: [Site!] @belongsToMany
    user: User! @belongsTo
}

enum Status {
    PENDING
    SUCCESSFUL
    FAILED
}