Skip to content

Instantly share code, notes, and snippets.

@codyromano
Created April 21, 2020 03:23
Show Gist options
  • Save codyromano/e87f3d1b300c4837a3f91f04811667fb to your computer and use it in GitHub Desktop.
Save codyromano/e87f3d1b300c4837a3f91f04811667fb to your computer and use it in GitHub Desktop.
const GET_CONVERSATION = gql`
query GetConversation($request: GetConversationInput!) {
getConversation(request: $request) {
conversation {
id
}
}
}
`;
type ExampleComponentProps = {
userName: string;
route: {
params: {
conversationId: string;
}
}
};
type QueryResponse = {
getConversation: {
conversation: {
status: string;
}
}
};
type QueryVars = {
variables: {
request: {
id: string;
}
}
};
const ExampleComponent = ({
data,
userName,
}: ExampleComponentProps & WithFocusQueryProps<QueryResponse, QueryVars>) => (
<SafeAreaView>
<Text>Hello, {userName}! {data.getConversation.conversation.status}</Text>
</SafeAreaView>
);
export default withFocusQuery({
query: GET_CONVERSATION,
getQueryVars: (props: ExampleComponentProps) => ({
variables: {
request: {
id: props.route.params.conversationId,
},
}
}),
})(ExampleComponent);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment