Skip to content

Instantly share code, notes, and snippets.

View pkellner's full-sized avatar
🏠
Working from home

Peter Kellner pkellner

🏠
Working from home
View GitHub Profile
<Button color="warning" onClick={() => {
const { speakers } = apolloClient.cache.readQuery({ query: GET_SPEAKERS });
apolloClient.cache.writeQuery({
query: GET_SPEAKERS,
data: {
speakers: {
datalist: [...speakers.datalist].sort((a,b) => a.id - b.id)
},
},
@pkellner
pkellner / button.html
Created October 14, 2020 21:34
Button Click To Sort GraphQL Cache
<Button color="warning" onClick={() => {
const { speakers } = apolloClient.cache.readQuery({ query: GET_SPEAKERS });
apolloClient.cache.writeQuery({
query: GET_SPEAKERS,
data: {
speakers: {
datalist: [...speakers.datalist].sort((a,b) => a.id - b.id)
},
},
});
const { ApolloServer, gql } = require("apollo-server");
const typeDefs = gql`
type Speaker {
id: ID!
first: String
last: String
favorite: Boolean
}
type SpeakerResults {
using System.Collections.Generic;
using System.Threading.Tasks;
using ClassLib.CacheExtension;
using EFLibSvcc.Models;
using Microsoft.Extensions.Caching.Memory;
namespace CarvedRock.Api.Repositories
{
public class RoomRepositoryCached
{
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using EFLibSvcc.Models;
using Microsoft.EntityFrameworkCore;
namespace CarvedRock.Api.Repositories
{
public class RoomRepository
{
using System;
using System.Collections.Concurrent;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.Extensions.Caching.Memory;
namespace ClassLib.CacheExtension
{
public class TCache<T>
{
const withCSS = require('@zeit/next-css');
require('dotenv').config();
const path = require('path');
const Dotenv = require('dotenv-webpack');
const withImages = require('next-images');
const withTypescript = require('@zeit/next-typescript');
const withOffline = require('next-offline');
//const isProd = process.env.NODE_ENV === 'production';
import { RunTypes } from '../components/codecamp/common/CodeCampInterfaces';
import getConfig from 'next/config';
const { publicRuntimeConfig } = getConfig();
/** A function that when called will return an environmental variable
* specified either in the .env file or the next.config.js defaults
* @param envKey value passed in which is environmental value without_DEV,_PROD or _STAGING
* @param devProdOrStaging
* @devProdOrStaging can only be "DEV","PROD", or "STAGING". If not included, then will default to process_env.NODE_ENV
* @returns returns the value after evaluating based on process.env.NODE_ENV
import axios from 'axios';
import { IUserInfo } from '../components/codecamp/common/CodeCampInterfaces';
//import getEnvParameters from './getEnvParameter';
//import getConfig from 'next/config';
//const { publicRuntimeConfig } = getConfig();
const fetchUserInfoPromise: Promise<{userInfo: IUserInfo} | {hasErrored: boolean,isServer: boolean,errorMessage: any}> = (cookieValue: string) => {
//$$$ TODO: check for cookieValue and if null, just return empty speaker so don't need to do check on every request
import React, { FunctionComponent } from 'react';
import axios, { AxiosResponse } from 'axios';
import useAxiosFetch from '../src/components/codecamp/common/hooks/useAxiosFetch';
import getConfig from 'next/config';
import App from '../src/App';
import { IUserInfo, Session } from '../src/components/codecamp/common/CodeCampInterfaces';
import fetchUserInfoPromise from '../src/utils/fetchUserInfoPromise';