Skip to content

Instantly share code, notes, and snippets.

View bignimbus's full-sized avatar
🙃

Jeff Auriemma bignimbus

🙃
View GitHub Profile
@bignimbus
bignimbus / codegen-migration.md
Last active March 21, 2025 18:30
Migrating from `apollo` CLI codegen to GraphQL Code Generator

Credit: Jerel Miller (June 2024)

I've been experimenting with the two tools to compare codegen outputs and I was able to get a config for codegen that gets close to the apollo CLI's output. Unfortunately its not 100% 1:1. The biggest difference between the two is the name of the file you import from and unfortunately graphql-codegen isn't configurable in a way that allows you to name the files how the apollo codegen tool does. First the config, then I'll talk about it:This requires 1 preset and 2 plugins:

const config: CodegenConfig = {
@bignimbus
bignimbus / @apollo+client+3.7.17.patch
Created December 10, 2024 21:03
Apollo Client / Kaspersky patch-package example
diff --git a/node_modules/@apollo/client/apollo-client.cjs b/node_modules/@apollo/client/apollo-client.cjs
index c8b1fdc..1b6755c 100644
--- a/node_modules/@apollo/client/apollo-client.cjs
+++ b/node_modules/@apollo/client/apollo-client.cjs
@@ -1805,17 +1805,17 @@ function selectHttpOptionsAndBodyInternal(operation, printer) {
}
function removeDuplicateHeaders(headers, preserveHeaderCase) {
if (!preserveHeaderCase) {
- var normalizedHeaders_1 = Object.create(null);
+ var normalizedHeaders_1 = {};
@bignimbus
bignimbus / ttl-example.js
Created November 7, 2024 18:26
Apollo Client TTL example
// credit: Ben Newman
// a possible workaround is to store the timestamp info in the field using field policy merge and read functions:
new InMemoryCache({
typePolicies: {
SomeType: {
fields: {
theField: {
read(existing) {
@bignimbus
bignimbus / redirect-to-docs.md
Last active September 15, 2023 18:18
github-boilerplates.md

Hi {{ name }}! Thanks for opening this Issue. I recommend reviewing this section of our docs: {{ title }}.

If nothing in the docs helps with what you're seeing, please consider posting in our Discord server or our Community Forum. The maintainers and other Apollo users are active on those platforms, they're great places to ask for help using Apollo {{ iOS/Client/Kotlin }}. In an effort to keep our Issues actionable, we're closing this Issue for now but please do feel free to re-open if there's a bug, documentation update, or feature idea that we should consider!

For more information about how to get the most out of the Apollo GraphQL Community, see this blog post 🚀

Keybase proof

I hereby claim:

  • I am bignimbus on github.
  • I am jeffauriemma (https://keybase.io/jeffauriemma) on keybase.
  • I have a public key ASCF2I-DD0nSd-2WFjybeqLVfE-bHCi9G6UlukU8Ibdq_Qo

To claim this, I am signing this object:

@bignimbus
bignimbus / Workflow.md
Last active January 30, 2019 17:37
Draft of HTML-CSS UI building workflow

Commit 1: enter all the content and order of how it will appear on the smallest supported screen. No structure, just literally only text and media nodes

Commit 2: enclose content in semantic tags. No layout considerations, just semantics. Headings get the appropriate <h#> tags, copy gets <p> tags, anchors get <a> tags, buttons get <button> tags, etc.

Commit 3: create an HTML layout out of block elements. <header>, <section>, <footer>, <nav>, <ul>, <ol>, etc. Sibling elements must have the same display value, otherwise nest them. E.g. a <span> can't be the sibling of a <div>. We still haven't written any CSS.

Commit 4: style all "inline" content, which encompasses elements with display: inline by default (e.g. text nodes, anchors, and spans). Styles should include resets, text colors, font sizes, line heights, font weights, etc. No margins, no padding, no heights, no widths (unless they are part of a CSS reset). No media queries, just get those inline elements styled for the s

const cropSvgToContentOnly = (svgElement) => {
const {
x,
y,
width,
height,
} = svgElement.getBBox();
const viewBoxValue = [x, y, width, height].join(' ');
svgElement.setAttribute('viewBox', viewBoxValue);
};
throw 'foo';
// throws an exception of type String and value "foo"
throw new Error('foo');
// throws an exception of type Error with message "foo"
foo();
// throws an exception of type ReferenceError (extends Error)
// with message "foo is not defined"
@bignimbus
bignimbus / example1.jsx
Last active March 3, 2018 03:34
React presentation source code examples
// From reactjs.org tutorial
class Square extends React.Component {
constructor(props) {
super(props);
this.state = { value: null };
}
render() {
return (
<button className="square" onClick={() => alert('click')}>
@bignimbus
bignimbus / example.spec.js
Created October 3, 2017 15:57
Async unit tests with Jest
const INTERVAL = 100;
function myFunction () {
setTimeout(() => {
console.log('hi');
}, INTERVAL);
}
describe('myFunction', () => {
it('should be testable', () => {