Skip to content
Permalink
Browse files

missed adding file

  • Loading branch information...
tadasant committed Jan 23, 2019
1 parent 71c4865 commit 82a40060058421da0f6e158ec01db9d6ac872105
Showing with 60 additions and 0 deletions.
  1. +60 −0 app/src/components/result/AnswerMapContainer.js
@@ -0,0 +1,60 @@
import gql from "graphql-tag";
import * as React from "react";
import { graphql } from "react-apollo";
import AnswerMap from './AnswerMap';

const AnswerSubscriptionContainer = (props) => {
if (!props.data.Answer) {
return null;
}
return <AnswerMap game={props.game} answer={props.data.Answer} />;
}

const GameSubscriptionContainer = (props) => {
if (!props.data.Game) {
return null;
}

const AnswerSubscriptionContainerWithData = withAnswerData(AnswerSubscriptionContainer);

return <AnswerSubscriptionContainerWithData game={props.data.Game} gameId={props.gameId} />;
}

const ANSWER_SUBSCRIPTION = gql`
subscription AnswerSubscription($gameId: uuid!) {
Answer(where: { gameId: { _eq: $gameId } }) {
latLocation
longLocation
playerID
}
}
`;

const GAME_SUBSCRIPTION = gql`
subscription GameSubscription($gameId: uuid!) {
Game(where: { id: { _eq: $gameId } }) {
questions {
latLocation
longLocation
location
}
}
}
`;

const withAnswerData = graphql(ANSWER_SUBSCRIPTION, {
options: ({ gameId }) => ({
variables: { gameId }
})
});

const withGameData = graphql(GAME_SUBSCRIPTION, {
options: ({ gameId }) => ({
variables: { gameId }
})
});


export default withGameData(GameSubscriptionContainer);


0 comments on commit 82a4006

Please sign in to comment.
You can’t perform that action at this time.