Skip to content
This repository was archived by the owner on Jul 16, 2024. It is now read-only.

Commit b82f2ae

Browse files
committed
Merge branch 'test-Dgraph-v1.0.6'
1 parent daf3774 commit b82f2ae

File tree

11 files changed

+14890
-3861
lines changed

11 files changed

+14890
-3861
lines changed

README.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,7 @@ A blazingly fast Stack Overflow clone running the real Stack Exchange dataset.
44

55
**NOTE: The repository is no longer being actively maintained by the Dgraph team. If something is broken, we'd happily accept a pull request from you, but won't fix anything ourselves.**
66

7-
**Update: I'll (MichelDiz) start a kind of "support" for this PJ, so right now I'm on Windows and I will create a Branch
8-
just for my tests. Some things may be different on other systems. I will not change anything drasticly on this branch, I will only modify some syntax changes and give some tips on how to handle this project. For this branch, read the file "syntax_changes.txt ".
7+
**UPDATE: This project is properly updated to work with version 1.0.6 of Dgraph. It's working as it should on MacOS and Linux. Only on the Windows platform are there problems that can be solved by starting JS Server and JS client separately. read the file "syntax_changes.md" for more details**
98

109
[Live](https://graphoverflow.dgraph.io)
1110

@@ -19,12 +18,14 @@ just for my tests. Some things may be different on other systems. I will not cha
1918

2019
### Dgraph
2120

22-
This app is currently compatible with Dgraph v0.8.1
21+
This app is currently compatible with Dgraph v1.0.6
2322

2423
1. Run Docker
2524

2625
docker run -it -p 8080:8080 -p 9080:9080 -v ~/dgraph:/dgraph --name dgraph dgraph/dgraph:v0.8.1 dgraph --bindall=true --memory_mb 2048
2726

27+
PS. You can also run this project with Dgraph binaries instead of Docker.
28+
2829
1. Choose, download and unarchive a data dump from https://archive.org/details/stackexchange, for example [lifehacks.stackexchange.com.7z](https://archive.org/download/stackexchange/lifehacks.stackexchange.com.7z)
2930

3031
1. Convert stackexchange data from relation to graph. From the current directory:

app/auth.js

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
11
import { Strategy as GitHubStrategy } from "passport-github";
2-
import { runQuery, getEndpointBaseURL } from "./helpers";
2+
import { runQuery, runMutation } from "./helpers";
33

44
// createUser persists a new user node
55
function createUser(accessToken, displayName, GitHubID) {
66
console.log("creating user...", accessToken);
7-
const query = `
8-
{
9-
set {
7+
const Nquads = `
108
<_:user> <DisplayName> "${displayName}" .
119
<_:user> <GitHubAccessToken> "${accessToken}" .
1210
<_:user> <GitHubID> "${GitHubID}" .
@@ -15,11 +13,9 @@ function createUser(accessToken, displayName, GitHubID) {
1513
<_:user> <LastAccessDate> "0" .
1614
<_:user> <Location> "Earth" .
1715
<_:user> <Type> "User" .
18-
}
19-
}
2016
`;
2117

22-
return runQuery(query)
18+
return runMutation(Nquads)
2319
.then(({ data }) => {
2420
const userUID = data.uids.user;
2521

@@ -32,7 +28,6 @@ function createUser(accessToken, displayName, GitHubID) {
3228

3329
// findUserByUID queries a user node with a given uid
3430
export function findUserByUID(uid) {
35-
console.log("finding user", uid);
3631
const query = `
3732
{
3833
user(func: uid(${uid})) {
@@ -101,7 +96,7 @@ export function configPassport(passport) {
10196
callbackURL: `${callbackURL}/api/auth/github/callback`
10297
},
10398
(accessToken, refreshToken, profile, cb) => {
104-
console.log(profile);
99+
// console.log(profile);
105100
const query = `
106101
{
107102
user(func: eq(GitHubID, ${profile.id})) {
@@ -118,9 +113,9 @@ export function configPassport(passport) {
118113
`;
119114
runQuery(query)
120115
.then(({ data }) => {
121-
console.log("data.user", data.user);
122116
// FIXME
123-
if (!data.user) {
117+
if (!data.user.length) {
118+
console.log("No user with this ID");
124119
createUser(
125120
accessToken,
126121
profile.username,
@@ -130,7 +125,6 @@ export function configPassport(passport) {
130125
});
131126
return;
132127
}
133-
134128
const user = data.user[0];
135129
cb(null, user);
136130
})

0 commit comments

Comments
 (0)