Hello everyone. What does it involve to write code...
# prisma-whats-new
s
Hello everyone. What does it involve to write code in ES6 in prismagraphql?
j
Hey @sakhmedbayev Where you want to make some ES6 code exactly?
s
in a resolver
j
you mean resolver with graphql-yoga?
s
I am using full-stack boilerplate with advanced node example
j
ok
s
I have mutation set in a separate folder
j
so yes, you can add some ES6 code depending of the version of NodeJS used
s
I am using > 9
I mean node version
j
normally no problem for ES6 code
if necessary, you can use Babel or polyfill for specific features
s
yes, this is my question, how to use them with prisma?
is there webpack setup involved?
j
is not related to prisma, but your NodeJS stack (like you can use TypeScript or not)
s
currently do not use TypeScript
do you have an example anywhere that I can take a look at?
or can you please point me to docs that can help?
j
yes, this is a starter from the Babel repo for a NodeJS stack: https://github.com/babel/example-node-server
but you maybe don’t need it
ES6 is supported at 97% since NodeJS v6
same thing for ES7 and already some features from ES8 and ESNext
s
do you work with prisma?
j
I’m currently develop a project using prisma
+ graphql-yoga but with TypeScript
s
do you recommend to go with TypeScript?
with TypeScript, I do not need to use babel. Is that correct?
j
I already develop some Angular project, so I use to develop with TS 🙂 Personally, I prefer it to plain JS for typed variable and used it inside Visual Studio Code to have a terrible auto-complete feature 😄
s
🙂
j
After, you can already change you file from
.js
to
.ts
and add the transpiler, it will work automatically
and next go step by step to implement some TS features
s
I am trying to implement auth solution from this kit to prisma backend
what do you use for auth?
j
I doesn’t need auth for the moment so i don’t start to look for the good solution
I know there are some example in the Prisma github repository to manage auth, but I don’t try it
s
there is auth0, but it is paid if you need custom email
j
and i look it and it’s really expensive 😄
s
yea, they are very raw
I mean auth solutions that graphcool or prisma provide
j
for the auth process, you may find more answer in the forum
s
I like auth in the kit I sent you but I need to move to prisma
and now I am struggle 🙂
that solution is tight to other part of the kit
j
after, you have a nodejs server, so Passport is maybe a good solution (it’s powerful but not the most simplest)
s
it seems that the trend is to use JWT
j
passport can be use with JWT, OAuth and other (like facebook ou google login)
it will help you to manage the user session
inside the NodeJS sever
s
but how it integrates with graphql
?
j
after you will have to develop effectively the session for the GraphQL server
s
this guy shows how to use just JWT with prisma

https://www.youtube.com/watch?v=nyE6shIRzxM&list=PLN3n1USn4xlmqhVdKMurNREwtiUpq-SFy

but his solution is not complete
no email confirmation, passport reset
j
wow, the tutorial looks good
but i don’t think i’m the good person to help you to add all the business logic you need (email confirmation, etc.)
s
I understand
j
and it still be about your nodejs, not prisma
s
can you show me you ts config file?
I mean your
j
prisma is just an “overlay” above your database
so the major part of your code depends of your nodejs
s
here is how prisma's package.json scipts look like
```
Copy code
"scripts": {
    "start": "nodemon -e js,graphql -x node -r dotenv/config src/index.js",
    "debug": "nodemon -e js,graphql -x node --inspect -r dotenv/config src/index.js",
    "playground": "graphql playground",
    "dev": "npm-run-all --parallel start playground",
    "build": "webpack"
  },
j
s
thanks
I will look at it
j
and also form this repo for the package.json scripts 😉
u’re welcome, don’t hesitate if you have some question about the boilerplate
there is a dedicated channel to talk about it
s
oh! nice!
am I correct in my assumption that i order to add babel transpile to my current setup, I need to change "start" script?
j
for
start
,
debug
and
build
but NodeJS v9 is like 100% compatible with ES6
so i think you may not need it
s
you see because my prisma resolvers are importing code from other parts of the kit I am constantly getting this kind of errors
Copy code
/Users/saidakhmedbayev/node_projects/mine/telosmediaorg/config/index.js:1
(function (exports, require, module, __filename, __dirname) { export { default as app } from './app';
                                                              ^^^^^^

SyntaxError: Unexpected token export
    at new Script (vm.js:51:7)
    at createScript (vm.js:138:10)
    at Object.runInThisContext (vm.js:199:10)
    at Module._compile (module.js:624:28)
    at Object.Module._extensions..js (module.js:671:10)
    at Module.load (module.js:573:32)
    at tryModuleLoad (module.js:513:12)
    at Function.Module._load (module.js:505:3)
    at Module.require (module.js:604:17)
    at require (internal/module.js:11:18)
j
ah yes
previously, I said nodejs is compatible about 97% with ES6
and you use the 3% not compatible 😄
and Babel can resolve it
because you use import/export (named as ES Module)
s
and TS too?
j
if you want to be nodeJS compliant, you will use
module.export
and
require
with TypeScript you can use import/export
s
Thank you so much for your help!
j
u’re welcome 🙂
s
are you a maintainer of the ts boilerplate?
j
edit => “”and Babel can resolve it”" It’s wrong, babel
can't
dot it
it’s why you may need webpack when you want to use import/export (or an other tools like browserify, etc.)
s
is it easier to try to go with TS?
j
it depends ^^
sometimes I add TS just to manage the import/export, but within use the type variables, Class or any TS feature
but i’m not sure that is the best way to reduce after the size of the code 😄
s
Javascript is crazy 🙂
j
😂
s
It is powerful but crazy 🙂 I used to work with Python
j
ahah, yes it’s a different world ^^
s
so many caveats with Javascript
I guess I will try to use TS and see where it will bring me 🙂
j
and it awlays evolve
personally, i start by learning Java and PHP during my studies, so I prefer TS when I need an OOP logic
s
evolution means mutations
ugliness 🙂
j
yes and big mutations btw
s
but perhaps, out of that we will get some beauty 🙂
alright, I do not want to keep you anymore. Thanks for your help. Is there any way to chat with you directly?
j
yes of course
you can...
s
Thanks
Have a good day!!!
👍
j
thanks, you too!