我是新的反应-本机,图形和Aws AppSync .我们试着构建一个使用aws appsync.When ireact本机运行android的反应本机应用程序,它正在抛出一个错误。
传递给解析器的不是一个有效的GraphQL,DocumentNode.you可能需要使用“graphql-tag”或其他方法将您的操作转换为文档。
请看一下
获取引用的图像url。
import { graphql, compose } from 'react-apollo';
import gql from 'graphql-tag';
const listMessages = graphql(gql`
query listMessages {
listMessages {
id
text
createdAt
sentBy {
id
name
}
}
}`)
const createMessage = graphql(gql`
mutation createMessage($text: String!, $sentById: ID!) {
createMessage(input : {
id : $sentById
text : $text
createdAt : "1/06/2018"
updateAt:"1/06/2018"
}){
sentBy {
id
name
}
}
}`)
export default compose(
graphql(createMessage,{
options: {
fetchPolicy: 'cache-and-network'
}
}, {name : 'createMessageMutation'}),
graphql(listMessages, {
options : {
fetchPolicy: 'cache-and-network'
}
}, {name: 'listMessagesQuery'})
)(Chat)上述代码是graphql的基本实现。
我真的找不到错误,请帮助me.Thanks!预先
发布于 2018-06-02 04:19:40
您将调用graphql函数两次--一次在listMessages和createMessage的定义中,然后在导出语句中。您需要更改定义用于查询的变量的方式:
const createMessage = gql`
mutation createMessage($text: String!, $sentById: ID!) {
createMessage(input : {
id : $sentById
text : $text
createdAt : "1/06/2018"
updateAt:"1/06/2018"
}) {
sentBy {
id
name
}
}
}`发布于 2019-08-13 00:47:10
您只能使用GQL来定义查询。
你可以任意使用。
不需要添加graphql。
import gql from 'graphql-tag';
const listMessages = gql
query listMessages {
listMessages {
id
text
createdAt
sentBy {
id
name
}
}
}https://stackoverflow.com/questions/50643033
复制相似问题