So how did I do on the coding challenge? I have no idea. But here's what I went through:
The README promised that there was a working, minimal implementation in the ZIP file. There was not. So the first thing I did was go through the How To GraphQL tutorial, which kinda gets you to the point of having a working Twitter clone. While going through it, I realized that the coding challenge was this tutorial, more or less.
Prisma is ridiculously difficult to run locally. It's a cloud-first solution, written in Scala. In fact, ${MEGACORP}
provided me with a Prisma instance running somewhere on AWS rather than ask me to try and run it on my laptop. So the first discovery was that part of the reason the example code they gave me wasn't working was that I didn't have a Prisma account; I had to log into Prisma and give it authentication via Github.
The next thing I realized was that, looking at the schema they provided me, it didn't look right. I ran the prisma generate
account and all these warnings and errors came back to me. Despite being only three months old, the schema provided was already deprecated; the @unique
attribute had been augmented by the @ID
attribute for data keys, and the syntax for date/time fields had changed. With the schema fixed, the Prisma account activated, and the database seeded, I actually started to see something in my "Twitter" feed.
It was time to turn my attention to the client.
Figuring out how to do login / logout was the hardest part. It involved all the moving parts, including authentication, and it was tricky. I ended up wrapping the entire app in a hand-written React Authentication.Context
object that provided hooks to the login
and logout
function, as well as a state that indicated if there was a user and who it was. I so missed Rust's sum types here; I wish Javascript had them, and in that form. (One of the wildest things I saw recently was that Typescript has sum types and enums, and they're not the same thing. I filed that under "What the whatting what?") But once it was working, it was working fine.
I did have one moment where I couldn't figure out how to banish the log-in popup. It was a two-stage asynchronous operation, one to handle the 'submit' even and another to handle the 'login' event. On a hunch, I wrapped the login handler in a console.log()
and it returned a Promise which contained the return value from the login, so I could use a successful Promise resolution as the event to call the .dismiss()
method. It worked, and it was elegant as hell, but I get the feeling it's rather un-React-y; it was a "do something" rather than "be something" implementation.
I wrote out a few decision tables and decided I could live with it.
After that, things accelerated: I quickly sketched out how I wanted it to look, how I wanted the toolbar and profile sidebar to update, and getting them to work was interesting. I learned a megaton of Material and Material-UI in the process, although I'm still not keen on Material's thematic engine.
I had a good time doing this. It's not the best use of my skills, but it's certainly satisfying to see things working in real-time, and I'm impressed with the tooling, at any rate.