Skip to content

Instantly share code, notes, and snippets.

View ardatan's full-sized avatar
🏠
Working @ home

Arda TANRIKULU ardatan

🏠
Working @ home
View GitHub Profile
schema
@link(url: "https://specs.apollo.dev/link/v1.0")
@link(url: "https://specs.apollo.dev/join/v0.3", for: EXECUTION) {
query: Query
}
directive @join__enumValue(graph: join__Graph!) repeatable on ENUM_VALUE
directive @join__field(
graph: join__Graph
@ardatan
ardatan / spotify-supergraph.graphql
Created May 23, 2025 00:09
spotify-supergraph.graphql
schema
@link(url: "https://specs.apollo.dev/link/v1.0")
@link(url: "https://specs.apollo.dev/join/v0.3", for: EXECUTION)
@link(url: "https://specs.apollo.dev/tag/v0.3")
{
query: Query
mutation: Mutation
subscription: Subscription
}
schema
@core(feature: "https://specs.apollo.dev/core/v0.2")
@core(feature: "https://specs.apollo.dev/join/v0.1", for: EXECUTION) {
query: Query
}
directive @core(as: String, feature: String!, for: core__Purpose) repeatable on SCHEMA
directive @join__field(
graph: join__Graph
import { JSONSchema } from './types';
type RequiredPropertyKeys<TProperties extends Record<string, JSONSchema>> = {
[K in keyof TProperties]: TProperties[K] extends { ['__optional']: true } ? never : K;
}[keyof TProperties];
const sharedHelpers = {
$format<TThis extends JSONSchema, TFormat extends string>(
this: TThis,
format: TFormat,
@ardatan
ardatan / spoiler.ts
Created February 22, 2023 10:22
Spoiler for new typed router
import { TypedResponseCtor } from "../typed-fetch-api";
import { TypedRouter } from "../typed-router";
const TypedResponseCtorObj = {} as TypedResponseCtor;
const typedRouter = {} as TypedRouter;
typedRouter.get<{
Request: {
QueryParams: {
import { request as httpRequest } from 'http';
import { request as httpsRequest } from 'https';
import { MeshPlugin } from '@graphql-mesh/types';
import { Readable } from 'stream';
function getRequestFnForProtocol(protocol: string) {
switch (protocol) {
case 'http:':
return httpRequest;
case 'https:':
@ardatan
ardatan / cf_openapi.json
Created November 18, 2022 14:38
CF OAS
This file has been truncated, but you can view the full file.
{
"name": "CloudflareAPI",
"baseUrl": "https://api.cloudflare.com/client/v4",
"operations": [
{
"method": "GET",
"path": "/accounts",
"type": "query",
"field": "accounts_list_accounts",
"description": "List all accounts you have ownership or verified access to.",
export function getLRUCache<V>(max = 1000) {
let storage: Record<string, V> = {}
let keys: string[] = []
return {
get(key: string) {
return storage[key]
},
set(key: string, value: V) {
queueMicrotask(() => {
if (storage[key] != null) {
@ardatan
ardatan / getAsyncIterableFromEventTarget.ts
Created December 17, 2021 11:24
getAsyncIterableFromEventTarget.ts
function getAsyncIterableFromEventTarget(eventTarget: EventTarget, eventName: string): AsyncGenerator<Event> {
    const pushQueue: Array<IteratorResult<Event>> = []
    const pullQueue: Array<(iteratorResult: IteratorResult<Event>) => void> = []
    let listening = true;
    function pushValue(event: Event) {
        if (pullQueue.length !== 0) {
            // It is safe to use the ! operator here as we check the length.
            pullQueue.shift()!({ value: event, done: false });
schema {
query: Query
mutation: Mutation
}
type TGraphEntity implements GraphEntity {
id: String!
}
interface GraphEntity {