我使用石墨烯和石墨烯-mongo。我的graphql模式有一个类似如下的类型: type Report {
id:ID!
name:String!
} 我针对这种类型的石墨烯类是 class Product(MongoengineObjectType):
class Meta:
model = MongoProduct 而mongoengine类是 class MongoProduct(mng.DynamicDocument):
name = mng.fields.StringField(required=True) 如何将该字段
我想测试我的graphql突变,它应该只设置一个HTTP cookie。
我使用石墨烯-django
class CookieTest(GraphQLTestCase):
def test_set_cookie(self):
response = self.query(...) # This should return WSGIRequest
cookie = response.COOKIES.get('myCookie') # This line throws an attrib error
self.assertIsNotNone(cookie)
我阅读了关于如何在解析器中使用和其他装饰器的说明。但是,如果不使用显式解析器(而是使用默认解析器),如何实施类似的访问控制?
在我的例子中,我将石墨烯与Django用户模型一起使用。我有以下几点:
class UserNode(DjangoObjectType):
class Meta:
model = User
filter_fields = ['first_name', 'last_name', 'id', 'email']
interfaces = (Node, )
我使用django和django石墨烯来生成graphql。
在我的应用程序中,我使用reactJS和。React引导表期望我为它传递一个对象数组,但不支持。
我在schema.py中创建了查询
class ApplicationNode(DjangoObjectType):
class Meta:
model = Application
filter_fields = ['name', 'sonarQube_URL']
interfaces = (relay.Node,)
class Query(Obj
我目前正在使用用于阿波罗客户端的vue-apollo包和带有django的VueJs栈,以及用于我的GraphQl应用程序接口的石墨烯-python。 下面我用vue-apollo做了一个简单的设置: import Vue from 'vue'
import { ApolloClient } from 'apollo-client'
import { HttpLink } from 'apollo-link-http'
import { InMemoryCache } from 'apollo-cache-inmemory'
i
我希望能够从给定的配置文件动态创建一个GraphQL服务器。例如,我的配置文件将包括哪些字段应该存在,并且其中一些字段将具有一个标志,将它们指示为主键或辅键,这些主键或辅键将映射到它们以获得一个解析器。如何实现动态创建石墨烯对象类型? 我尝试使用石墨烯的示例代码并向其中添加字段。但它不会接受它们。我试着深入研究元数据并更新一些选项,但也没有成功。 class User(graphene.ObjectType):
id = graphene.ID()
name = graphene.String()
class Query(graphene.ObjectType):
我正在使用石墨烯构建graphQL模式,并使用mypy进行静态类型检查。schema的代码开始如下:
from typing import Dict, List, NamedTuple, Union
import graphene
class PossibleAnswer(graphene.ObjectType):
"""Object representing single possible answer, a pair of key and text."""
paId = graphene.String(
我正在为GraphQL使用石墨烯-django框架。除外键外,我可以检索的所有字段
# models.py
from django.db import models
from django.contrib.auth.models import User
from users.models import UserProfile
class Video(models.Model):
title = models.TextField()
description = models.TextField()
author = models.ForeignKey(User, on