在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
开源软件名称(OpenSource Name):Urigo/graphql-cli开源软件地址(OpenSource Url):https://github.com/Urigo/graphql-cli开源编程语言(OpenSource Language):TypeScript 91.2%开源软件介绍(OpenSource Introduction):GraphQL CLIHelp us to improve new GraphQL CLI. Check out the new structure and commands below! Feel free to contact us in Discord channel. We would love to hear your feedback. Features
InstallYou can install the CLI using yarn global add graphql-cli The equivalent npm global install will also work. Migration from 3.x.x to 4.x.xImportant: many aspects of GraphQL CLI syntax and structure have changed in 4.x.x. Please check out the Migration Guide to learn more. Usage / InitializationAt the heart of a project created using GraphQL CLI is the GraphQL Config configuration file. For starters, this configuration lets the cd CLI tools know where all of the GraphQL documents and operations are. For more information about GraphQL Config, you can click here to learn more. The most straightforward way to launch a GraphQL CLI-capable project with a working GraphQL Config setup is to use the npx graphql-cli init After a series of questions from the command-prompt, the system will use the inputs and selected project templates to generate a working project complete with a GraphQL Config setup. The GraphQL Config file is generated referencing the necessary files and ecosystem plugins. You can also get started with GraphQL CLI by creating your own GraphQL Config file using an editor of your choice. Starting with a filename schema: "server/src/schema/**/*.graphql"
documents: "client/src/documents/**/*.graphql" This is now a valid YAML-syntax GraphQL Config file. Using Finally, one of the options with Plugin SystemEach command in GraphQL CLI is a seperate package, so you can have your own plugins or use the ones we maintain. You can have those commands by installing them like To configure a command/plugin, you need to update the schema:
./server/src/schema/**/*.ts:
require: ts-node/register
documents: ./client/src/graphql/**/*.ts
extensions:
codegen:
generates:
./server/src/generated-types.d.ts:
plugins:
- typescript
- typescript-resolvers
./client/src/generated-types.tsx:
plugins:
- typescript
- typescript-operations
- typescript-react-apollo
config:
withHooks: true
graphback:
model: './model/*.graphql'
plugins:
graphback-schema:
outputPath: './src/schema/schema.graphql'
... For a detailed example check out a template file here. Some of the available Plugins are:
# ...
extensions:
diff:
baseSchema: git:origin/master:schema.graphql
More plugins are definitely welcome! Please check the existing ones to see how to use GraphQL Config and GraphQL CLI API. ContributingPlease read through the contributing guidelines Writing your own pluginGraphQL CLI supports custom plugins, you can find a tutorial and example here Help & CommunityJoin our Discord chat if you run into issues or have questions. We're excited to welcome you to the community! |
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论