Skip to content

Instantly share code, notes, and snippets.

@crucialfelix
Last active September 5, 2017 11:03
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 crucialfelix/15b51ea0350b002f8b6995b3d4a6fc5a to your computer and use it in GitHub Desktop.
Save crucialfelix/15b51ea0350b002f8b6995b3d4a6fc5a to your computer and use it in GitHub Desktop.
import gql from "graphql-tag";
import React from "react";
interface Props {
message: any;
}
export default class Message extends React.PureComponent<Props, undefined> {
public render() {
return <div>message body</div>;
}
static fragments = {
message: gql`
fragment Message on Message {
id
body
createdOn
messageType
data
author
}
`
};
}
// Here is a common way that fragments are included in queries
import Message from "./Message";
const query = gql`
query Messages($threadKey: String!) {
viewer {
id
messages(threadKey: $threadKey) {
edges {
node {
id
...Message
}
}
}
}
}
${Message.fragments.message}
`;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment