1

正如您在标题中所读到的,我正在尝试使用此插件通过 graphql (mutations) 添加数据。这是我的代码:

mutation{
  allMoltinProduct (id:"d348fcc5-3e1c-5ebb-a1bb-9a4716bb56af",name:"Camiseta",formatted:"7.49"){
    edges {
      node {
        id
        name
        description
        meta {
          display_price {
            with_tax {
              amount
              currency
              formatted
            }
          }
        }
        mainImageHref
        mainImage {
          childImageSharp {
            sizes(maxWidth: 400) {
              ...GatsbyImageSharpSizes
            }
          }
        }
        slug
        material
        max_watt
        bulb_qty
        bulb
        sku
        finish
      }
    }
  }
}

它给了我以下错误。


{
  "errors": [
    {
      "message": "Schema is not configured for mutations.",
      "locations": [
        {
          "line": 1,
          "column": 1
        }
      ],
      "stack": [
        "GraphQLError: Schema is not configured for mutations.",
        "    at getOperationRootType (D:\\gatsby-store\\node_modules\\graphql\\utilities\\getOperationRootType.js:28:13)",
        "    at executeOperation (D:\\gatsby-store\\node_modules\\graphql\\execution\\execute.js:210:61)",
        "    at executeImpl (D:\\gatsby-store\\node_modules\\graphql\\execution\\execute.js:104:14)",
        "    at execute (D:\\gatsby-store\\node_modules\\graphql\\execution\\execute.js:64:35)",
        "    at D:\\gatsby-store\\node_modules\\express-graphql\\index.js:152:16",
        "    at runMicrotasks (<anonymous>)",
        "    at processTicksAndRejections (internal/process/task_queues.js:95:5)"
      ]
    }
  ],
  "extensions": {}
}

这是我自己添加自己的graphql中已经存在的产品之一:

{
  "data": {
    "allMoltinProduct": {
      "edges": [
        {
          "node": {
            "id": "1981f542-8a23-460c-83b5-008130ced9a6",
            "name": "Crown",
            "description": "",
            "meta": {
              "display_price": {
                "with_tax": {
                  "amount": 37500,
                  "currency": "USD",
                  "formatted": "$375.00"
                }
              }
            },
            "mainImageHref": "",
            "mainImage": {
              "childImageSharp": {
                "sizes": {
                  "base64": "",
                  "aspectRatio": 1,
                  "src": "/static/7cf7d1a319dc9018fe0704ddff047bd4/497c6/14be2d71-b84a-494a-924f-a78ed2bfcb1e.png",
                  "srcSet": "",
                  "sizes": "(max-width: 400px) 100vw, 400px"
                }
              }
            },
            "slug": "crown",
            "material": "Steel",
            "max_watt": "5W",
            "bulb_qty": "12",
            "bulb": "GU10",
            "sku": "CWLP100BLK",
            "finish": "Matt Black"
          }
        }
      ]
    }
  },
  "extensions": {}
}

是否可以使用此插件仅进行查询以显示数据但不能修改或添加新数据?如果可能的话,我该如何实施以及在哪里实施?问候并感谢您的宝贵时间。

4

0 回答 0