Я создаю окно жалобы в своем приложении для пользователя моего приложения, но я получаю ошибку при выполнении запроса на мутацию в Reaction-native.Я пытаюсь удалить ошибку за 3 часа:
Error is raised {"graphQLErrors":[{"path":null,"locations":[{"line":2,"column":3,"sourceName":null}],"message":"Validation error of type SubSelectionRequired: Sub selection required for type Complain of field createComplain @ 'createComplain'"}],"networkError":null,"message":"GraphQL error: Validation error of type SubSelectionRequired: Sub selection required for type Complain of field createComplain @ 'createComplain'"}
Я попробовал все решение в github, запрос выполняется на сервере aws. Пожалуйста, помогите
Вот моя реакция-нативный код:
enter code here
import { withApollo, compose,graphql,Query } from 'react-apollo'
import gql from 'graphql-tag';
// true means invalid, so our conditions got reversed
class AddComplaint extends Component {
constructor(props){
super(props);
this.state={
title: '',
content:'',
date:'',
userMob:'',
photo:'',
}
}
componentDidMount(){
AsyncStorage.getItem("ownerDetails").then(value => {
this.setState({
userMob:JSON.parse(value).verifyUser.mob,
})
})
}
// Insert owner complaint
AddOwnerComplaint = () => {
const { userMob , title , content} = this.state;
if (title == '') {
// here place your signup l sogic
alert ('Title cannot be Empty');
}
else if (content == '') {
// here place your signup l sogic
alert ('Content cannot be Empty');
}
this.props.AddOwnerComplaint({
variables: {
"socName": "sohel-khan-p",
"userMob": userMob,
"title": title,
"content": content,
// "date": "12/21/2018",
"status": "pending",
'societyName' : "sohel khan p",
'flatNo':12,
"photo": {
"bucket": "dsad",
"key": "vnds",
"region": "dbas"
}
}
})
.then(({ data }) => {
if(data.createComplain == null){
alert("Something went wrong");
}else{
console.log('Added complaint sucessfully' + data);
}
})
.catch((err) => {
console.log(`${JSON.stringify(err)}`);
//alert("Please check username or password")
});
}
}
render () {
return (
<Container>
{ Platform.OS === 'ios'? <Header style={Global.AppHeaderBackGround}>
<Body>
<Title style={Global.AppHeaderTextStyle}>Complaint Box</Title>
</Body>
</Header> : <Header style={Global.AppHeaderBackGround}>
<Col></Col>
<Col style={{paddingTop:'4%'}}><Body>
<Title style={Global.AppHeaderTextStyle}>Complaint Box</Title>
</Body></Col>
<Col></Col>
</Header>}
<Content padder>
<Card>
<CardItem header>
<Text style={Global.IconColor}>Subject</Text>
</CardItem>
<CardItem>
<Item regular rounded>
<Input
placeholder="Subject / Title"
onChangeText={title => this.setState ({title})}
/>
</Item>
</CardItem>
<CardItem header>
<Text style={Global.IconColor}>
Write Your Complaint/Feedback Here...
</Text>
</CardItem>
<CardItem>
<TextInput
placeholder="Comment Here"
blurOnSubmit={false}
returnKeyType={"go"}
multiline={true}
numberOfLines={20}
underlineColorAndroid={"transparent"}
autoCapitalize={"none"}
autoCorrect={false}
style={[Global.InputTextareStyle,styles.textbox]}
onChangeText={content => this.setState ({content})}
/>
</CardItem>
<CardItem footer>
<Button onPress={this.AddOwnerComplaint} rounded style={Global.button}>
<Text style={{letterSpacing: 10}}>SUBMIT</Text>
</Button>
</CardItem>
</Card>
</Content>
</Container>
);
}
}
const complaintPage = compose(
withApollo,
graphql(AddOwnerComplaint,{name: "AddOwnerComplaint"}),
)(AddComplaint)
export default complaintPage;
мой код мутации
enter code here import gql from 'graphql-tag'
export default gql`
mutation createComplain(
$socName: String!
$userMob: String!
$title: String
$content: String
$photo: S3ObjectInput
# $date: String!
$status: String
$flatNo: Int
$societyName: String
){
createComplain(input:{
socName: $socName
userMob: $userMob
title: $title
content: $content
photo: $photo
# date: $date
status: $status
flatNo: $flatNo
societyName: $societyName
})
}
`