Skip to content

Instantly share code, notes, and snippets.

View mvantellingen's full-sized avatar

Michael van Tellingen mvantellingen

  • Utrecht, The Netherlands
View GitHub Profile
func (obj *ScopedPrice) UnmarshalJSON(data []byte) error {
type Alias ScopedPrice
if err := json.Unmarshal(data, (*Alias)(obj)); err != nil {
return err
}
if obj.Value != nil {
obj.Value = mapDiscriminatorTypedMoney(obj.Value)
}
return nil
}
#%RAML 1.0 DataType
(package): Common
displayName: Price
type: object
properties:
id?:
type: string
value:
type: Money
country?:
type Price struct {
ID string `json:"id,omitempty"`
}
# type Product string
f := jen.NewFile("mypackage")
f.Type().Id("Product).String().Line()
f.Save("output.go")
@mvantellingen
mvantellingen / supergraph.ts
Last active February 25, 2025 05:47
Hive `createSupergraphManager`
/**
* This file re-implements hive's createSupergraphManager to return a fetcher
* which uses node's native fetch api. This is required due to errors when
* the fetch library used by hive is instrumented by the observability package.
*
* See https://github.com/graphql-hive/console/issues/6359#issuecomment-2679100600
*/
import type { SupergraphSDLFetcherOptions } from "@graphql-hive/apollo";
import { createHash } from "@graphql-hive/core";
import fetchRetry from "fetch-retry";
/**
* This decorator (rscDecorator) is used to prevent infinite re-renders of
* rsc pages.
*
* See https://github.com/storybookjs/storybook/issues/30317#issuecomment-2615462131
*
* Rewritten to be compatible with Storybook 9
*/
let PrevStory: PartialStoryFn<ReactRenderer, object> | null = null;