Question on SSS: The test object from graphcool in...
# prisma-whats-new
p
Question on SSS: The test object from graphcool includes
body.context
but when the real subscription invokes a webtask I don’t have access to
body.context
, specifically what I want to do is check
body.context.graphcool.projectId
so that I know which project is calling the webtask ( I have a dev and production project), is this the expected behaviour? and if so how do I know what project is calling the function?
body of test object
Copy code
{
  "data": {
    "Score": {
      "updatedFields": [
        "updatedAt"
      ],
      "node": {
        "id": "cj73kpo2x00043k62dd28hxuj",
        "value": 22051,
        "scorecard": {
          "id": "cj73kpo2y00053k62prudb5o9",
          "total": 76023
        }
      }
    }
  },
  "context": {
    "request": {
      "sourceIp": "test-ip",
      "headers": {},
      "httpMethod": "post"
    },
    "graphcool": {
      "pat": "test-pat",
      "projectId": "test-project-id",
      "alias": "test-alias"
    },
    "environment": {},
    "auth": {
      "nodeId": "test-node-id",
      "typeName": "test-type",
      "token": "test-token"
    },
    "sessionCache": {}
  }
}
body of object from real subscription:
Copy code
"body":{
    "data":
    {"Score":
      {"updatedFields":null,
        "node":
          {"id":"cj73n0uz215r20135nkxpyank","value":55,
        "scorecard":{"id":"cj5j2ur0nf5lt0111gpt45otg","total":0}
        }
      }
    }
a
Context is not available yet for RP and SSS, only for Schema Extensions
p
Thanks!
p
Any ideas on how to know which project is triggering the function? I tried creating a header like
projectid: devproject
but it does not seem to be set
a
SSS functions are specific to the project. So you can put the projectid in the function code as variable
p
Ok so I would have to create two separate webtasks (one for dev project and 1 for production project) ? I wanted to have 1 webtask and check if it was being called by my dev or production project and then use the appropriate api endpoint in my function. I don’t want to have to maintain 2 seperate webtasks for each SSS but for now I guess it’s not that big of an issue
a
If you use inline functions, you can't. If you use an external webhook, you can pass the projectid as a header from both projects
You still have to hardcode the header in both projects, but at least the webtask will not have it hardcoded.
p
hmm let me try that again, when I tried setting headers they were not being set.
Thanks for all the help by the way 🙂 you are always quick to answer
😎 1
a
I remember there's an issue where headers are not set in test run. But in real runs, they should be set
p
ok yes, you are right about that! thanks so mu
😎 1
much*