最近我将我的Visual Studio更新到最新版本17.5.1,我的目标sdk版本是NET 7.0 SDK(v7.0.102)。现在我有一个构建错误,指出“访问路径‘obj\berry’被拒绝”。有人遇到同样的错误并提出解决此问题的建议吗?
我使用草莓和草莓-django-plus构建了一个 GraphQL API ,该 API 使用 Django 托管在 http://localhost:8000/graphql 上。我能够在本地主机页面上使用 GraphiQL 成功与 API 交互。
\n我现在尝试使用GraphQL 代码生成器和 React 查询从前端访问 API。当我运行命令时yarn graphql-codegen,出现以下错误:
\xe2\x9c\x94 Parse configuration\n \xe2\x9d\xaf Generate outputs\n \xe2\x9d\xaf Generate src/generated/graphql.ts\n \xe2\x9c\x96 Load GraphQL schemas\n \xe2\x86\x92 Failed to load schema\n Load GraphQL documents\n Generate\n \xe2\x9d\xaf Generate ./graphql.schema.json\n \xe2\x9c\x96 Load GraphQL schemas\n \xe2\x86\x92 Failed to load schema\n Load GraphQL documents\n Generate\n\n\n Found 2 errors\n\n \xe2\x9c\x96 ./graphql.schema.json\n Failed to load schema from http://localhost:8000/graphql:\n\n Request with …Run Code Online (Sandbox Code Playgroud) django graphql graphql-codegen react-query strawberry-graphql
哪个库更适合与新的 django 项目集成?
我红色了文档,但仍然不知道每个文档在产品环境中的性能如何或更容易集成。
我之前使用石墨烯与我在工作中所做的一些 Pipefy 代码集成,但我对 graphql 还很陌生,现在不知道我应该走什么路。
我想创建一个以字典作为参数的突变。有特定于实现的原因想要这样做,而不是为 dict 对象创建类型/模式。
# types.py
import typing
@strawberry.type
class Thing:
data: typing.Dict
Run Code Online (Sandbox Code Playgroud)
# resolvers.py
import typing
from .types import Thing
def create_config(data: typing.Dict) -> Thing:
pass
Run Code Online (Sandbox Code Playgroud)
# mutations.py
import strawberry
from .types import Thing
from .resolvers import create_thing
@strawberry.type
class Mutations:
create_thing: Thing = strawberry.mutation(resolver=create_thing)
Run Code Online (Sandbox Code Playgroud)
mutation {
createThing(data: {}) {}
}
Run Code Online (Sandbox Code Playgroud)
从阅读文档来看,没有与 dict 等效的 GraphQL 标量。当我尝试测试时,这个编译错误证明了这一点:
TypeError: Thing fields cannot be resolved. Unexpected type 'typing.Dict'
我的本能是将 dict 扁平化为 JSON 字符串并以这种方式传递。这看起来不优雅,这让我认为有一种更惯用的方法。我应该从这里去哪里?
我们如何在 Strawberry GraphQL Resolver 中获取请求的字段
query {
test {
label
}
}
Run Code Online (Sandbox Code Playgroud)
如何获取label解析器中的字段?
我努力了:
info.field_nodes[0].selection_set.selections
Run Code Online (Sandbox Code Playgroud)
但它没有返回我想要的