小编Mah*_*esh的帖子

如何在GraphQL中插入(Array)字段列表进行变异查询

最近我开始研究GraphQL,我能够在没有任何问题的情况下在平面模式中插入数据但是当涉及数据数组时,我收到的错误就像

 { "errors": [ {  "message": "Must be input type" } ]}
Run Code Online (Sandbox Code Playgroud)

我正在使用邮递员测试我的查询,我的变异查询是

mutation M { 

AddEvent
  (

    title: "Birthday event"   

    description:"Welcome to all" 

    media:[{url:"www.google.com", mediaType:"image" }]

    location:[{address:{state:"***", city:"****"}}]

   ) 

{title,description,media,location,created,_id}}
Run Code Online (Sandbox Code Playgroud)

这是我的事件架构:

EventType = new GraphQLObjectType({
  name: 'Event',
  description: 'A Event',
  fields: () => ({
   _id: {
      type: GraphQLString,
      description: 'The id of the event.',
    },
     id: {
      type: GraphQLString,
      description: 'The id of the event.',
    },
    title: {
      type: GraphQLString,
      description: 'The title of the event.',
    },
     description: { …
Run Code Online (Sandbox Code Playgroud)

node.js mongodb-query graphql

22
推荐指数
2
解决办法
1万
查看次数

标签 统计

graphql ×1

mongodb-query ×1

node.js ×1