Skip to content

Commit

Permalink
ci: rename mater to main
Browse files Browse the repository at this point in the history
  • Loading branch information
daphnesmit committed Jan 22, 2021
1 parent b4db9f2 commit 8648410
Show file tree
Hide file tree
Showing 7 changed files with 10 additions and 17 deletions.
7 changes: 0 additions & 7 deletions example/next.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,6 @@ module.exports = withPlugins(
],
{
webpack: (config) => {
config.module.rules.forEach((rule) => {
const ruleContainsTs = rule.test && rule.test.toString().includes('ts|tsx');

if (ruleContainsTs && rule.use && rule.use.loader === 'next-babel-loader') {
rule.include = undefined;
}
});
return config;
},
},
Expand Down
2 changes: 1 addition & 1 deletion example/pages/_app.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { ApolloProvider } from '@apollo/client'
import { AppProps } from 'next/app'
import { withApolloServerSideRender } from '../../dist/with-next-apollo-tree-walker'
import { withApolloServerSideRender } from '../../dist/with-next-apollo-tree-walker.module'
import '../styles/globals.css'
import { useApollo } from '../utils/apolloClient'

Expand Down
2 changes: 1 addition & 1 deletion example/utils/apolloClient.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { ApolloClient, HttpLink, InMemoryCache, NormalizedCacheObject } from '@apollo/client'
import { concatPagination } from '@apollo/client/utilities'
import { useMemo } from 'react'
import { useApolloCacheController } from '../../dist/with-next-apollo-tree-walker'
import { useApolloCacheController } from '../../dist/with-next-apollo-tree-walker.modern'

let apolloClient: ApolloClient<NormalizedCacheObject> | undefined

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
},
"release": {
"branches": [
"master",
"main",
{
"name": "develop",
"prerelease": true
Expand Down
4 changes: 2 additions & 2 deletions src/ApolloCacheController.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import { ApolloCache } from '@apollo/client/cache/core/cache';
import { NormalizedCacheObject } from '@apollo/client/cache/inmemory/types';
import React, { Context } from 'react';
import React from 'react';

export type ApolloCacheControllerCacheSnapshot = Record<string, NormalizedCacheObject>;

export class ApolloCacheController {
private cacheInstances = new Map<string, ApolloCache<NormalizedCacheObject>>();
private storedExtractedCache = new Map<string, NormalizedCacheObject>();
private static context: Context<ApolloCacheController | null>;
private static context: React.Context<ApolloCacheController | null>;

public static getContext() {
if (!ApolloCacheController.context) {
Expand Down
6 changes: 3 additions & 3 deletions src/useApolloCacheController.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { InMemoryCache, NormalizedCacheObject } from '@apollo/client';
import { useContext, useMemo } from 'react';
import React from 'react';

import { ApolloCacheController } from './ApolloCacheController';

Expand All @@ -9,12 +9,12 @@ interface UseApolloCacheController {
}

export const useApolloCacheController = (): UseApolloCacheController => {
const context = useContext(ApolloCacheController.getContext());
const context = React.useContext(ApolloCacheController.getContext());
if (context === null) {
throw new Error('Cannot use useApolloCacheController without context provider');
}

const state = useMemo(() => ({
const state = React.useMemo(() => ({
register: (name: string, cache: InMemoryCache) => context.registerCache(name, cache),
extract: (name: string) => context.getExtractedCache(name)
}),[])
Expand Down
4 changes: 2 additions & 2 deletions src/withApolloTreeWalker.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { NextPage, NextPageContext } from 'next';
import App, { AppContext } from 'next/app';
import Head from 'next/head';
import React, { useMemo } from 'react';
import React from 'react';

import { ApolloCacheController, ApolloCacheControllerCacheSnapshot } from './ApolloCacheController';
import { getDisplayName } from './utils/getDisplayName';
Expand All @@ -19,7 +19,7 @@ export default function withApolloTreeWalker(
const ApolloCacheControllerContext = ApolloCacheController.getContext();

function WithApollo({ apolloCacheControlSnapshot, apolloCacheControl, ...props }: IWithApolloProps) {
const _apolloCacheController = useMemo<ApolloCacheController>(
const _apolloCacheController = React.useMemo<ApolloCacheController>(
() => apolloCacheControl || new ApolloCacheController(), [apolloCacheControl],
);

Expand Down

0 comments on commit 8648410

Please sign in to comment.