menu

Clever Beagle

Chat with other product developers and get help with Clever Beagle's tools and resources.

Channels
Team

Adding Event type

January 1, 2020 at 9:03pm

Adding Event type

January 1, 2020 at 9:03pm
Hey, I am trying to start with the new pup version, by adding an event type to pup. I added an Event type, query an Event mongo object in the api section, added a query and a page to list the events in the pages section, added everything in the schema (in api.js).
But on startup i still get "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 ". This error occurs on the page that i created to show the events. (export default compose( graphql(events))(Events);
Is there anything that I am missing in the process to add a new object type (such as an event)?
Kr
W

January 1, 2020 at 9:35pm
Hi, can you show more your code? The full component perhaps, thanks.
like-fill
1
  • reply
  • like
Sure. This the code for the page that should show the events.
import React from 'react';
import PropTypes from 'prop-types';
import { compose, graphql } from 'react-apollo';
import { events } from '../../queries/Events.gql';
const Events = ({ data }) => (
<div className="Events">
<div className='module'>
<div className="module-head">
<h3 className="pull-left">test</h3>
</div>
<div className="module-body">
{data.events.length ? <Table striped responsive>
<thead>
<tr>
<th />
<th />
</tr>
</thead>
<tbody>
{data.events.map(({ _id, title}) => (
<tr key={_id}>
<td>{_id}</td>
<td>{title}</td>
</tr>
))}
</tbody>
</Table> : <Alert bsStyle="warning">nothing to see here</Alert>}
</div>
</div>
</div>
);
Events.propTypes = {
data: PropTypes.object.isRequired
};
export default compose(
graphql(events)
)(Events);
The query itself which is imported is the following
query events {
events {
_id
isPublic
title
updatedAt
createdAt
}
}
Edited
  • reply
  • like

January 2, 2020 at 8:59am
what is the content of import { events } from '../../queries/Events.gql';
If you have only one query there, convert those import-statement to import events from '../../queries/Events.gql';
  • reply
  • like
Off course... Silly mistake. Tx. It is working fine now.
like-fill
1
  • reply
  • like
I usually type some temp query to the end of gql-file so that there is always at least two queries.. :D
  • reply
  • like

January 5, 2020 at 10:35pm
Thanks for helping out with this !
  • reply
  • like