[英]Unrecognized arguments in graphql mutation
I'm curretly following this tutorial on Meteor/Apollo/GraphQL, and having huge troubles to make a mutation with arguments/variables.我目前正在关注有关 Meteor/Apollo/GraphQL 的本教程,并且在使用参数/变量进行突变时遇到了巨大的麻烦。 Here is my code and some notes at the bottom !
这是我的代码和底部的一些注释!
type Resolution {
_id: String!
name: String!
}
type Mutation {
createResolution(name: String!): Resolution
}
import Resolutions from './resolutions'
export default {
Query: {
resolutions() {
return Resolutions.find({}).fetch()
}
},
Mutation: {
createResolution(obj, args, context) {
console.log('hey i get here')
}
}
}
import React, { Component } from 'react'
import gql from 'graphql-tag'
import { graphql } from 'react-apollo'
const createResolutionQuery = gql`
mutation createResolution($name: String!) {
createResolution(name: $name) {
_id
}
}
`
class ResolutionForm extends Component {
submitForm = () => {
this.props
.createResolution({
variables: {
name: this.name.value
}
})
.then(d => console.log('data received'))
.catch(e => console.log(e))
}
render() {
return (
<div>
<input type="text" ref={input => (this.name = input)} />
<button onClick={this.submitForm}>Submit</button>
</div>
)
}
}
export default graphql(createResolutionQuery, {
name: 'createResolution'
})(ResolutionForm)
So I think my problem is with the mutation arguments (brilliant deduction I know), but I can't figure out where is the typo or where I'm missing something.所以我认为我的问题在于变异参数(我知道的精彩演绎),但我无法弄清楚错字在哪里或我在哪里遗漏了什么。 Help from somebody with a fresh look is welcome, thanks :)
欢迎有新面貌的人提供帮助,谢谢:)
Reinstall npm packages solved the issue.重新安装 npm 包解决了这个问题。
All looks good I made a small change and added it as a pull request to your github repo.一切看起来都不错,我做了一个小改动,并将其作为拉取请求添加到您的 github 存储库中。
createResolution(obj, {name}, context) {
console.log('hey i get here')
const id = Resolutions.insert({
name,
})
return Resolutions.findOne(id)
}
Running on my machine I get no errors.在我的机器上运行我没有错误。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.