Я пытаюсь создать форму для создания нового объявления, но получаю сообщение об ошибке:
Invariant Violation: Argument of undefined passed to parser was not a valid GraphQL DocumentNode. You may need to use 'graphql-tag' or another method to convert your operation into a document
Я впервые использую GraphQL и Apollo, поэтому я не 'Не знаю, что мне делать.
Компонент CreateAnnouncement:
import { compose, graphql } from 'react-apollo';
import { addAnnouncement as addAnnouncementMutation } from '../../../mutations/Announcements.gql';
import { announcement as announcementQuery } from '../../../queries/Announcements.gql';
class CreateAnnouncement extends React.Component {
...
}
export default compose(
graphql(announcementQuery, {
options: ({ match }) => ({
variables: {
_id: match.params._id,
},
}),
}),
***THE ERROR POINTS NEXT LINE***
graphql(addAnnouncementMutation, {
name: 'addAnnouncement',
}),
)(CreateAnnouncement);
' .. /. ./../mutations/Announcements.gql'
#import "../fragments/Announcements.gql"
mutation addAnnouncement($title: String!, $description: String, $date: String!) {
addAnnouncement(title: $title, description: $description, date: $date) {
...AnnouncementAttributes
}
}
"../ fragments / Announcements.gql"
fragment AnnouncementAttributes on Announcement {
_id
title
description
date
createdAt
updatedAt
}