Isaac Lee Morris
09/21/2017, 6:41 AMnilan
09/21/2017, 6:42 AMnilan
09/21/2017, 6:42 AMsimple/v1
instead of the string you passed inIsaac Lee Morris
09/21/2017, 6:43 AMnilan
09/21/2017, 6:43 AM<https://api.graph.cool/simple/v1/cj7mnyihh05nl01453hnia715>
with simple/v1
nilan
09/21/2017, 6:43 AMIsaac Lee Morris
09/21/2017, 6:44 AMIsaac Lee Morris
09/21/2017, 6:44 AMnilan
09/21/2017, 6:44 AMnilan
09/21/2017, 6:44 AMIsaac Lee Morris
09/21/2017, 6:44 AM"use latest"
const fromEvent = require("graphcool-lib").fromEvent;
module.exports = function (event) {
const api = fromEvent(event).api("simple/v1");
const query = `
allDataSources {
id
}
`;
return api.request(query)
.then(function (result) {
return {
data: {
dataSourceIds: ["hello", "schema"]
}
};
})
};
Isaac Lee Morris
09/21/2017, 6:44 AMnilan
09/21/2017, 6:44 AMconst { fromEvent } = require("graphcool-lib");
needs to say const fromEvent = require("graphcool-lib").fromEvent;
I believeIsaac Lee Morris
09/21/2017, 6:45 AMnilan
09/21/2017, 6:46 AMIsaac Lee Morris
09/21/2017, 6:46 AMIsaac Lee Morris
09/21/2017, 6:46 AMIsaac Lee Morris
09/21/2017, 6:47 AMnilan
09/21/2017, 6:47 AMCreate a new Permanent Access Token (PAT) in project settings. It needs to have the same name as the function to make it available in the execution context of the function.
nilan
09/21/2017, 6:47 AMIsaac Lee Morris
09/21/2017, 6:52 AMnilan
09/21/2017, 6:52 AMIsaac Lee Morris
09/21/2017, 6:52 AMnilan
09/21/2017, 6:52 AMIsaac Lee Morris
09/21/2017, 6:53 AMtype ValidDataSourcesPayload {
dataSourceIds: [String!]!
}
extend type Query {
validDataSources(componentTypeId: String!): ValidDataSourcesPayload
}
Isaac Lee Morris
09/21/2017, 6:53 AMnilan
09/21/2017, 6:53 AMnilan
09/21/2017, 6:53 AMnilan
09/21/2017, 6:53 AMnilan
09/21/2017, 6:54 AMIsaac Lee Morris
09/21/2017, 6:54 AMIsaac Lee Morris
09/21/2017, 6:55 AM{
"data": {
"validDataSources": null
},
"errors": [
{
"locations": [
{
"line": 2,
"column": 3
}
],
"path": [
"validDataSources"
],
"code": 5000,
"message": "A function returned an unhandled error. Please check the logs for executionId 'us-west-2:simple:cj7u3qjj3r6h401324kojkqt2'",
"requestId": "us-west-2:simple:cj7u3qjj3r6h401324kojkqt2"
}
]
}
nilan
09/21/2017, 6:55 AMquery { allDataSources { id } }
nilan
09/21/2017, 6:56 AMIsaac Lee Morris
09/21/2017, 6:57 AMIsaac Lee Morris
09/21/2017, 6:57 AMIsaac Lee Morris
09/21/2017, 6:57 AMIsaac Lee Morris
09/21/2017, 6:58 AMIsaac Lee Morris
09/21/2017, 6:58 AMnilan
09/21/2017, 6:58 AMIsaac Lee Morris
09/21/2017, 6:59 AMnilan
09/21/2017, 6:59 AMIsaac Lee Morris
09/21/2017, 7:19 AMnilan
09/21/2017, 7:21 AM