Skip to content

Instantly share code, notes, and snippets.

@jaunesarmiento
Last active December 14, 2021 13:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jaunesarmiento/f7903a80d5b0874a4b1aef7aad3e4e2a to your computer and use it in GitHub Desktop.
Save jaunesarmiento/f7903a80d5b0874a4b1aef7aad3e4e2a to your computer and use it in GitHub Desktop.
useEffect(() => {
API
.graphql(graphqlOperation(messagesByChannelID, {
channelID: '1',
sortDirection: 'ASC'
}))
.then((response) => {
const items = response?.data?.messagesByChannelID?.items;
if (items) {
setMessages(items);
}
})
}, []);
@mimoricom
Copy link

Displaying Sorted Messages
Let’s sort the messages for real this time! Open src/App.js and instead of importing listMessages, import messagesByChannelId. Note the lowercase “d” in ID here.

But!

import { messagesByChannelId } from './graphql/queries';
returns

src\App.js
Line 15:33: 'messagesByChannelID' is not defined no-undef

Search for the keywords to learn more about each error.

import { messagesByChannelID } from './graphql/queries';
returnes

Compiled successfully!

Is it right or wrong?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment