我对GraphQL文档浏览器有问题。正如您在图片上所看到的,它存在俄语文本问题,它显示了一些经过两次编码的字符串,例如“ \\ u041c \\ u043e \\ u0441”。该如何解决?
已添加:
现在我做了一个这样的补丁(请参阅.replace('\\\\', '\\')
部分)
from graphql.type import introspection
def resolver(input_val, *_):
if input_val.default_value is None:
return None
if isinstance(input_val.default_value, str):
return introspection.print_ast(introspection.ast_from_value(input_val.default_value, input_val)).replace('\\\\', '\\')
return introspection.print_ast(introspection.ast_from_value(input_val.default_value, input_val))
introspection.__InputValue = introspection.GraphQLObjectType(
"__InputValue",
description="Arguments provided to Fields or Directives and the input fields of an "
"InputObject are represented as Input Values which describe their type "
"and optionally a default value.",
fields=lambda: introspection.OrderedDict(
[
("name", introspection.GraphQLField(introspection.GraphQLNonNull(introspection.GraphQLString))),
("description", introspection.GraphQLField(introspection.GraphQLString)),
("type", introspection.GraphQLField(introspection.GraphQLNonNull(introspection.__Type))),
(
"defaultValue",
introspection.GraphQLField(
type=introspection.GraphQLString,
resolver=resolver,
),
),
]
),
)