Skip to content

Instantly share code, notes, and snippets.

View lastmjs's full-sized avatar

Jordan Last lastmjs

View GitHub Profile
export async function userOwnsDirectiveResolver(next, source, args, context) {
if (source[args.field] === await getUserId(context)) {
return await next();
}
else {
throw new Error('Not authorized');
}
}
const ultimateSchemaString = mergeTypes([
readFileSync('./schema/datamodel.graphql').toString(),
readFileSync('./schema/dataops.graphql').toString(),
readFileSync('./schema/directives.graphql').toString(),
readFileSync('./generated/prisma.graphql').toString()
], {
all: true
});
const ultimateSchema = makeExecutableSchema({
typeDefs: ultimateSchemaString,
# This is where we define any custom resolvers, and where we add custom directives to any generated Prisma resolvers
type AuthPayload {
token: String!
user: User!
}
type Mutation {
# Custom resolvers
signup(email: String!, password: String!): AuthPayload!
import {GraphQLServer} from 'graphql-yoga';
import {makeExecutableSchema} from 'graphql-tools';
import {
Prisma,
Query,
Mutation
} from './generated/prisma';
import {readFileSync} from 'fs';
import {parse} from 'graphql';
import {
@lastmjs
lastmjs / block-full-stack-mentor-assessment.md
Last active August 25, 2019 18:11
Full Stack Mentor - Candidate Assessment

JavaScript

Hey Student,

Oh dear, this is a tricky one. It's definitely messed me up in the past. What's happening here is an issue of scoping and closures. A few things to point you in the right direction:

  1. Study block scoping versus function scoping in JavaScript
  2. Study JavaScript's variable declarators, var, let, and const, and understand the differences between their uses
  3. Study up a bit on closures in JavaScript
  4. With your new knowledge, try to make btnNum block scoped instead of function scoped
# This file is automatically @generated by Cargo.
# It is not intended for manual editing.
version = 3
[[package]]
name = "ahash"
version = "0.7.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fcb51a0695d8f838b1ee009b3fbf66bda078cd64590202a864a8f3e8c4315c47"
dependencies = [
#![allow(warnings, unused)]
use azle_vm_value_derive::{CdkActTryIntoVmValue, CdkActTryFromVmValue};
use candid::{Decode, Encode};
use rand::Rng as _AzleTraitRng;
use slotmap::Key as _AzleTraitSlotMapKey;
use std::convert::TryInto as _AzleTraitTryInto;
use std::str::FromStr as _AzleTraitFromStr;
thread_local! {
static BOA_CONTEXT_REF_CELL : std::cell::RefCell < boa_engine::Context < 'static >> =
{ struct Hooks; impl boa_engine::context::HostHooks for Hooks { fn utc_now(& self) ->
@lastmjs
lastmjs / gist:d058b2c8133b1cf45262883b3429b1be
Last active March 19, 2024 05:19
Boa/QuickJS Benchmarks Comparison
This compares Boa and QuickJS against these benchmarks: https://bellard.org/quickjs/bench.html
From these numbers we have evidence to believe that Azle's performance can be improved ~28x by switching to QuickJS.
We also have evidence from https://bellard.org/quickjs/bench.html that QuickJS could be improved up to 2x without compilation/JIT, and that compiled languages have one order of magnitude improvement over interpreted languages.
Boa:
target/release/boa combined.js
PROGRESS Richards