简体   繁体   English

变异令牌一路返回 null Graphql

[英]Mutation token all way return a null Graphql

I try to create a token using JWT and a GraphQL server我尝试使用 JWT 和 GraphQL 服务器创建令牌

在此处输入图像描述

I just have this resolver.我只有这个解析器。 在此处输入图像描述

But when I try to do the consults:但是当我尝试进行咨询时:

mutation authenticatedUser($input:authenticatedUserInput){
    authenticatedUser(input:$input){
      token
    }
    
  }

I just get this:我只是得到这个:

{
  "data": {
    "authenticatedUser": {
      "token": null
    }
  }
}

This is how I am using the server:这就是我使用服务器的方式:

const server = new ApolloServer({
    typeDefs,
    resolvers,
})

What I am doing wrong here?我在这里做错了什么? I am new to GraphQL.我是 GraphQL 的新手。 Thanks for any help in advance.感谢您提前提供任何帮助。

In this case, I go deep in apollo documentation and I have to return something like this.在这种情况下,我 go 深入阿波罗文档,我必须返回类似的内容。

authenticatedUser: (_, { input }) => {
      const {email} = input;
      const token = jwt.sign({ email }, process.env.SECRET_KEY, { expiresIn:'24h' });
      return {token}
    }
  },

no like不喜欢

return token

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 我的graphql服务器变异返回空值 - my graphql server mutation return null value 如何从graphql突变而不是null返回新记录 - how to return new record from graphql mutation instead of null 为什么 graphql 返回“不能返回 null of non-nullable field mutation.createAccnt” - why is graphql returning “cannot return null of non-nullable field mutation.createAccnt” 在 graphql 中更新/编辑用户数据(不能为不可空字段 Mutation.updateUser 返回 null) - Updating/editing user data in graphql(Cannot return null for non-nullable field Mutation.updateUser) GraphQL 错误:无法为不可为空的字段 Mutation.deleteComment 返回 null - GraphQL Error: Cannot return null for non-nullable field Mutation.deleteComment Graphql突变返回null,但数据库已更新 - Graphql mutation returning null, but database is updated 使用JavaScript定义GraphQL查询/突变的聪明方法 - Clever way to define a GraphQL Query/Mutation with JavaScript 在添加新架构字段后,aws cdk nextjs graphql 突变无法为不可空类型返回 null - aws cdk nextjs graphql mutation cannot return null for non-nullable type after adding in new schema field 当没有数据返回时,GraphQL 变异返回类型应该是什么? - What should be the GraphQL mutation return type when there is no data to return? 使用函数生成器将值返回到GraphQL Mutation中的outputFields - Return value to outputFields in GraphQL Mutation using a Function Generator
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM