GabeStah / dgraph-twitter-clone

Dgraph Twitter Clone
8 stars 1 forks source link

Cannot get the project to run out of the box #28

Open boucher opened 3 years ago

boucher commented 3 years ago

I've cloned the project, and created a running dgraph instance with the linked docker-compose.yml (slightly modified to add an ip whitelist, since otherwise it doesn't allow incoming connections).

Unfortunately, I cannot get the data generator step of building to work. If I use the interactive query boxes from the tutorial, the API shows this error:

{
  "errors": [
    {
      "message": "Unsupported Content-Type. Supported content types are application/json, application/graphql+-,application/dql",
      "extensions": {
        "code": "ErrorInvalidRequest"
      }
    }
  ]
}

But this is being masked by the error being thrown in the regenerator, which is an invalid JSON error on trying to parse the response, which seems to be two errors concatenated together rendering them invalid as a JSON string:

{"errors":[{"message":"Invalid Content-Type","extensions":{"code":"ErrorInvalidRequest"}}]}{"errors":[{"message":"Unsupported Content-Type. Supported content types are application/json, application/rdf","extensions":{"code":"ErrorInvalidRequest"}}]}

Here's the JS level error:

error: DgraphAdapterHttp.mutate, payload: Serialization {
  statusCode: 200,
  success: false,
  uri: '',
  message: 'User created.',
  request: {
    'user.createdAt': 2021-01-05T21:24:18.521Z,
    'user.favorites': [ [length]: 0 ],
    'user.friends': [ [length]: 0 ],
    'user.retweets': [ [length]: 0 ],
    'user.avatar': 'https://s3.amazonaws.com/uifaces/faces/twitter/thehacker/128.jpg',
    'user.description': 'Cumque a tenetur et est. Et recusandae incidunt. Non aliquid provident ducimus atque et omnis consectetur.',
    'user.email': 'Jacklyn.Bauch@example.com',
    'user.location': 'Larsontown, Timor-Leste',
    'user.name': 'Dayton Muller',
    'user.screenName': 'Carolanne_Glover',
    'user.url': 'http://malvina.org'
  },
  data: {
    'user.createdAt': 2021-01-05T21:24:18.521Z,
    'user.favorites': [ [length]: 0 ],
    'user.friends': [ [length]: 0 ],
    'user.retweets': [ [length]: 0 ],
    'user.avatar': 'https://s3.amazonaws.com/uifaces/faces/twitter/thehacker/128.jpg',
    'user.description': 'Cumque a tenetur et est. Et recusandae incidunt. Non aliquid provident ducimus atque et omnis consectetur.',
    'user.email': 'Jacklyn.Bauch@example.com',
    'user.location': 'Larsontown, Timor-Leste',
    'user.name': 'Dayton Muller',
    'user.screenName': 'Carolanne_Glover',
    'user.url': 'http://malvina.org'
  }
}, mutationType: 1, error: FetchError: invalid json response body at http://localhost:8080/mutate reason: Unexpected token { in JSON at position 91
    at ./dgraph-twitter-clone/api/node_modules/node-fetch/lib/body.js:50:31
    at processTicksAndRejections (node:internal/process/task_queues:93:5) {
  name: 'FetchError',
  message: 'invalid json response body at http://localhost:8080/mutate reason: Unexpected token { in JSON at position 91',
  type: 'invalid-json',
} {"service":"api","timestamp":"2021-01-05 13:24:18"}

I've been trying to figure out where in the code I could inject an application/json content type header, but haven't been able to figure out which abstraction layer is actually generating an HTTP request.

boucher commented 3 years ago

Seems like the issue is probably a dgraph version mismatch between the current version and whatever this was designed to support. Would be helpful to know which version was expected.

I did manage to force the appropriate json header, and now the code is requesting a URL that returns a 404 every time it tries to perform an operation (e.g. /commit/40005).