首页 > 解决方案 > 在 GraphQl 中定义解析器

问题描述

我刚刚开始学习 GraphQl 并遇到了解析器。我们可以在解析器中使用普通函数和箭头函数。

有什么特别的原因为什么我们会使用一个而不是另一个?两者似乎都工作正常。使用普通函数或箭头函数有什么好处吗?

// Using Arrow Functions
    me: () => {
      return {
        id: '122',
        name: 'lorem',
        email: 'lorem@ipsum.com',
        age: null
// Using Normal Function
    me(){
      return {
        id: '122',
        name: 'lorem',
        email: 'lorem@ipsum.com',
        age: null

哪一种是首选的方法?

标签: graphql

解决方案


推荐阅读