While creating the api
# prisma-whats-new
i
While creating the api
n
what type of function is it?
you need to say
simple/v1
instead of the string you passed in
i
That's basically what I'm doing
n
replace
<https://api.graph.cool/simple/v1/cj7mnyihh05nl01453hnia715>
with
simple/v1
in line 5
i
Looks like my event object doesn't have the "graphql" object in eventcontext
Yeah, I replaced that
n
what's the function type?
ah
i
Copy code
"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"]
                }
            };
    	})
};
Schema extension
n
const { fromEvent } = require("graphcool-lib");
needs to say
const fromEvent = require("graphcool-lib").fromEvent;
I believe
i
Updated, but same error
n
did you create root token with the same name as the function? (formerly called permanent authentication token)
i
I did not
I bet that's it
Is there documentation for that?
n
Create 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.
only in the function examples (we're currently revisiting our docs)
i
Does that need to be copied anywhere in the function source?
n
no
i
(I created the PAT with matching name "validDataSources") and still getting same error
n
I'm having a look 🤔
i
Copy code
type ValidDataSourcesPayload {
  dataSourceIds: [String!]!
}

extend type Query {
  validDataSources(componentTypeId: String!): ValidDataSourcesPayload
}
That's the SDL
n
ah
sorry
it's probably because you are executing test run and it's not setting the context correctly
can you try to run it from the Playground instead?
i
Yeah I tried that
Copy code
{
  "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"
    }
  ]
}
n
your query needs to say
query { allDataSources { id } }
then it should work from the playground
i
👍🏾
Working from playground
Thank you sir
Is there a good way to debug schema extensions?
Somewhere I can view console logs?
n
you can see the logs in the functions view
i
Check
n
with the new CLI, you can hook into the log stream
i
What command do I use for that?
n
I'll share a link to the forum thread when it's back up... 🙂