-
Notifications
You must be signed in to change notification settings - Fork 70
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Sashko Stubailo
committed
Apr 19, 2016
1 parent
9673fff
commit 19fb586
Showing
6 changed files
with
68 additions
and
20 deletions.
There are no files selected for viewing
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
# meteor starter kit | ||
|
||
A simple kit to start experimenting with Apollo and Meteor. | ||
|
||
### Running it | ||
|
||
``` | ||
meteor npm install | ||
meteor | ||
``` | ||
|
||
### Learn more | ||
|
||
Learn more [in the docs](http://docs.apollostack.com/)! |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +1,56 @@ | ||
import React, { Component } from 'react'; | ||
import { connect } from 'react-apollo'; | ||
import { Meteor } from 'meteor/meteor'; | ||
import { createContainer } from 'meteor/react-meteor-data'; | ||
|
||
const App = ({ currentUser }) => { | ||
const App = ({ userId, currentUser }) => { | ||
console.log(userId, currentUser); | ||
return ( | ||
<div> | ||
<LogInButtons /> | ||
<pre>{JSON.stringify(currentUser, null, 2)}</pre> | ||
<button onClick={currentUser.refetch}>Refetch!</button> | ||
{ userId ? ( | ||
<div> | ||
<pre>{JSON.stringify(currentUser, null, 2)}</pre> | ||
<button onClick={currentUser.refetch}>Refetch!</button> | ||
</div> | ||
) : 'Please log in!' } | ||
</div> | ||
) | ||
} | ||
|
||
// This container brings in Apollo GraphQL data | ||
const AppWithData = connect({ | ||
mapQueriesToProps() { | ||
return { | ||
currentUser: { | ||
query: ` | ||
{ | ||
currentUser { | ||
emails { | ||
address | ||
verified | ||
mapQueriesToProps({ ownProps }) { | ||
if (ownProps.userId) { | ||
return { | ||
currentUser: { | ||
query: ` | ||
query getUserData ($id: String!) { | ||
user(id: $id) { | ||
emails { | ||
address | ||
verified | ||
} | ||
randomString | ||
} | ||
} | ||
} | ||
`, | ||
}, | ||
}; | ||
`, | ||
variables: { | ||
id: ownProps.userId, | ||
}, | ||
forceFetch: true, | ||
}, | ||
}; | ||
} | ||
}, | ||
})(App); | ||
|
||
export default AppWithData; | ||
// This container brings in Tracker-enabled Meteor data | ||
const AppWithUserId = createContainer(() => { | ||
console.log("running", Meteor.userId()) | ||
return { | ||
userId: Meteor.userId() || false, | ||
}; | ||
}, AppWithData); | ||
|
||
export default AppWithUserId; |
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