[英]How to configure GraphQL extension for VSCode?
I'm trying to configure VSCode GraphQL extension, but its info is some obscure for me.我正在尝试配置 VSCode GraphQL扩展,但它的信息对我来说有些模糊。
I have this basic Flutter project structure:我有这个基本的 Flutter 项目结构:
.
├── analysis_options.yaml
├── android
├── assets
├── lib
│ ├── graphql
│ │ └── *.gql
│ ├── main.dart
│ ├── private
│ │ └── graphql.config.json
│ └── shared
├── pubspec.lock
├── pubspec.yaml
├── README.md
├── test
└── tutorial_with_hasura_server.iml
I've created graphql.config.json
into ./lib/private
directory with this setting:我已经使用以下设置将
graphql.config.json
创建到./lib/private
目录中:
{
"schema": {
"request": {
"url": "https://hasura.io/learn/graphql",
"method": "POST",
"postIntrospectionQuery": true,
"options": {
"headers": {
"Authorization": "Bearer 1234567890123456789"
}
}
}
}
}
Meanwhile in VSCode settings.json
I've added this line:同时在 VSCode
settings.json
我添加了这一行:
"graphql-config.load.filePath": "./lib/private/graphql.config.json",
I'm trying to run a simple GraphQL query operation which is stored in a file with extension GQL located in ./lib/graphql
directory, but no result, no error message, nothing at all.我正在尝试运行一个简单的 GraphQL 查询操作,该操作存储在
./lib/graphql
目录中扩展名为 GQL 的文件中,但没有结果,没有错误消息,什么都没有。 What am I missing?我错过了什么?
This config worked for me:这个配置对我有用:
{
"extensions": {
"endpoints": {
"default": {
"url": "https://hasura.io/learn/graphql",
"headers": {
"Authorization": "Bearer 1234567890123456789"
}
}
}
}
}
If that doesn't work, you might need to wrap it in projects:如果这不起作用,您可能需要将其包装在项目中:
{
"projects": {
"lib": {
"extensions": {
"endpoints": {
"default": {
"url": "https://hasura.io/learn/graphql",
"headers": {
"Authorization": "Bearer 1234567890123456789"
}
}
}
}
}
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.