is there an alternative way to handle this now?
# prisma-whats-new
w
is there an alternative way to handle this now?
n
yes! the current situation and possible future approaches are being discussed here: https://www.graph.cool/forum/t/validation-best-practices/797?u=nilan
w
thanks @nilan, but I still didn't found how to make the external call on current situation, in my case I need to hit a third part service to check if a given property exists (in my case, if a github users exists), is there an option to handle that outside of PRE_WRITE available now?
n
yes, that would be done in
TRANSFORM_ARGUMENT
w
I might be missing something basic, but I can't get that to work there, seems like every time I try to call
fetch
the script stops compiling without giving me any error message (it seems to fallback to the latest working version, ignoring new code)
this is the code I'm trying to run:
Copy code
'use latest'
require('isomorphic-fetch');

module.exports = async function (event) {
  const query = `
    user(login: "${event.data.github}") {
	  id
	}
  `;
  
  console.log("bla")
  
  const req = await fetch("<https://api.github.com/graphql?access_token=...>", {
    method: "post",
    headers: {"content-type" "application/json"},
    body: JSON.stringify({query})
  });
  
  const json = await req.json();
  console.log(json);
  
  return {data: event.data};
};
n
could you create a new forum thread so we can discuss the code there? https://www.graph.cool/forum/ 🙂
ah
`async`/`await` is not supported currently
w
ok, I did tried with promises basic too, but same result:
Copy code
'use latest'
require('isomorphic-fetch');

module.exports = function (event) {
  const query = `
    user(login: "${event.data.github}") {
	  id
	}
  `;
  
  return fetch("<https://api.github.com/graphql?access_token=...>", {
    method: "post",
    headers: {"content-type" "application/json"},
    body: JSON.stringify({query})
  }).then((r) => {
    return r.json()
  }).then((response) => {
    console.log(response);	
    return {data: event.data}
  }).catch((err) => {
    console.log(error);
    return {error: 'Could not connect to Movie API'};
  });
};
when I try to log
console.log(fetch)
, it logs null, is that normal?
n
could we move this discussion to the Forum? 🙂
w
sure, creating now