我在我的项目中使用 graphql-relay
在我的 grapgql 中运行此查询时:
{
viewer{
boRelayCustomerInfo(_id:"59267769de82262d7e39c47c") {
edges {
node {
id
}
}
}
}
}
我给出了这个错误:
"message": "arraySlice.slice is not a function"
我的查询代码是:
import {
GraphQLID,
GraphQLNonNull,
} from 'graphql'
import {
connectionArgs,
connectionFromPromisedArray,
} from 'graphql-relay'
import { customerConnection } from '@/src/schema/type/customer/CustomerType'
import { CustomerModel, ObjectId } from '@/src/db'
export default {
type: customerConnection.connectionType,
args: {
...connectionArgs,
_id: {
type: new GraphQLNonNull(GraphQLID),
},
},
resolve: (_, args) => connectionFromPromisedArray(
CustomerModel.findOne({_id: ObjectId(args._id)}),
args,
),
}
请告诉我们,如何在中继中只返回一条记录。