Django Vue阿波罗。查询不';t工作返回400错误请求
我正在用Vue cli构建前端,用Django和Graphene构建后端。变异可以正常工作,但查询不能 当我从GraphiQL运行相同的查询时,效果很好 前端Django Vue阿波罗。查询不';t工作返回400错误请求,django,vue.js,vue-apollo,Django,Vue.js,Vue Apollo,我正在用Vue cli构建前端,用Django和Graphene构建后端。变异可以正常工作,但查询不能 当我从GraphiQL运行相同的查询时,效果很好 前端 @vue/cli 4.1.2 vue阿波罗3.0.2 后端 python 3.8 django 3.0.2 石墨烯django 2.8.0 django graphql jwt 0.3.0 querys.js Home.vue 在Firefox中安装扩展Graphql并发现我的错误后,感谢您的帮助 { "errors": [
- @vue/cli 4.1.2
- vue阿波罗3.0.2
- python 3.8
- django 3.0.2
- 石墨烯django 2.8.0
- django graphql jwt 0.3.0
在Firefox中安装扩展Graphql并发现我的错误后,感谢您的帮助
{
"errors": [
{
"message": "Cannot query field \"is_active\" on type \"UserType\". Did you mean \"isActive\"?",
"locations": [
{
"line": 4,
"column": 5
}
]
}
]
}
更改为isActive
查询工作正常
<script>
import { ME_QUERY } from '@/graphql/queries'
export default {
name: 'home',
async mounted () {
await this.$apollo
.query({
query: ME_QUERY
})
.then((result) => {
console.log(result)
})
.catch(({ graphQLErrors }) => {
graphQLErrors.map(({ message, locations, path }) => console.log(`Error Message: ${message}, Location: ${locations}, Path: ${path}`))
})
}
}
</script>
from django.contrib.auth import authenticate, login, get_user_model
import graphene
from graphene_django import DjangoObjectType
import graphql_jwt
from graphql_jwt.decorators import jwt_cookie
class UserType(DjangoObjectType):
class Meta:
model = get_user_model()
class ObtainJSONWebToken(graphql_jwt.JSONWebTokenMutation):
user = graphene.Field(UserType)
@classmethod
def resolve(cls, root, info, **kwargs):
return cls(user=info.context.user)
class Query(graphene.ObjectType):
me = graphene.Field(UserType)
def resolve_me(root, info):
user = info.context.user
if user.is_anonymous:
raise Exception('Authentication failure!!')
return user
class Mutation(graphene.ObjectType):
# token_auth = graphql_jwt.ObtainJSONWebToken.Field()
verify_token = graphql_jwt.Verify.Field()
refresh_token = graphql_jwt.Refresh.Field()
revoke_token = graphql_jwt.Revoke.Field()
log_in = ObtainJSONWebToken.Field()
schema = graphene.Schema(query=Query, mutation=Mutation)
{
"errors": [
{
"message": "Cannot query field \"is_active\" on type \"UserType\". Did you mean \"isActive\"?",
"locations": [
{
"line": 4,
"column": 5
}
]
}
]
}