Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@jovercao/egg-graphql

Package Overview
Dependencies
Maintainers
1
Versions
14
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@jovercao/egg-graphql

egg graphql plugin

  • 0.1.13
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

egg-graphql


该项目派生自egg-graphql,npm包名更换为@jovercao/egg-graphql

使用方法

  • 架构文件

egg-graphq的基础上添加了以下功能:

  1. 添加 #import 指令的支持,以支持文件拆分功能,详见下文
  2. 添加代码编译报错提示(精确到行列),帮助你迅速找到grahql错误文件位置
  3. 解决了对graphql及graphql-tools版本依赖过旧带来的问题。

API

  • ctx.connector, 目录 app/graphql/connector/ 下的js/ts文件会被映射到ctx.connector对象中
  • app.resolver, 目录 app/graphql/resolver/ 下的js/ts文件会被合并并映射到app.resolver对象中
  • app.graphql.schema,GraphQLSchema类型
  • app.graphql.resolver, 同app.resolver
  • ctx.service.graphql, 服务端gql查询器
    • ctx.service.graphql.execute(gql, variables, operationName): Promise
    • ctx.service.graphql.query(gql, variables, operationName): Promise
    • ctx.service.graphql.mutation(gql, variables, operationName): Promise

gql文件支持 #import指令使用方式

目录结构如下:

  • src
    • user
      • schema.graphql
      • user.graphql
      • extFields.graphql

文件内容如下:

# schema.graphql
#import ./user.graphql

type Query {
  user(id: Int!): User!
}
# user.graphql
type User {
  name: String!
  age: Int!
  password: String
  #import ./extFields.graphql
}
# extFields.graphql
enabled: Boolean!
createAt: Date!
updateAt: Date!

编译后结果:

type User {
  name: String!
  age: Int!
  password: String
  enabled: Boolean!
  createAt: Date!
  updateAt: Date!
}

type Query {
  user(id: Int!): User!
}

Keywords

FAQs

Package last updated on 09 Nov 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc