Last active
September 5, 2017 11:03
-
-
Save crucialfelix/15b51ea0350b002f8b6995b3d4a6fc5a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | |
} | |
` | |
}; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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