标签: strawberry-graphql

由于草莓摇摇 graphql 客户端错误而导致 c# .net 构建错误 - “访问路径 'obj\\berry' 被拒绝”

最近我将我的Visual Studio更新到最新版本17.5.1,我的目标sdk版本是NET 7.0 SDK(v7.0.102)。现在我有一个构建错误,指出“访问路径‘obj\berry’被拒绝”。有人遇到同样的错误并提出解决此问题的建议吗?

.net c# graphql strawberry-graphql strawberryshake

9
推荐指数
1
解决办法
2032
查看次数

GraphQL 代码生成器 - 无法从 http://localhost:8000/graphql 加载架构 - 使用 GET/HEAD 方法的请求不能有正文

我使用草莓草莓-django-plus构建了一个 GraphQL API ,该 API 使用 Django 托管在 http://localhost:8000/graphql 上。我能够在本地主机页面上使用 GraphiQL 成功与 API 交互。

\n

我现在尝试使用GraphQL 代码生成器和 React 查询从前端访问 API。当我运行命令时yarn graphql-codegen,出现以下错误:

\n
\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

7
推荐指数
2
解决办法
1万
查看次数

在新项目中,石墨烯还是草莓?为什么?

哪个库更适合与新的 django 项目集成?

我红色了文档,但仍然不知道每个文档在产品环境中的性能如何或更容易集成。

我之前使用石墨烯与我在工作中所做的一些 Pipefy 代码集成,但我对 graphql 还很陌生,现在不知道我应该走什么路。

python django graphene-python strawberry-graphql

7
推荐指数
1
解决办法
3180
查看次数

草莓 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 字符串并以这种方式传递。这看起来不优雅,这让我认为有一种更惯用的方法。我应该从这里去哪里?

python graphql strawberry-graphql

3
推荐指数
1
解决办法
4802
查看次数

在 Strawberry GraphQL Resolver 中获取请求的字段

我们如何在 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)

但它没有返回我想要的

python-3.x strawberry-graphql

3
推荐指数
1
解决办法
2022
查看次数