Mirror: The highly customizable and versatile GraphQL client with which you add on features like normalized caching as you grow.
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Fix regression where rootDirs caused dist/types to disappear (#579)

* fix regression where rootDirs caused dist/types to dissapear

* remove debugStack stuff in populate since these aren't used

* lint files

* add changeset

authored by

Jovi De Croock and committed by
GitHub
fcb58885 81be6238

+107 -54
+6
.changeset/loud-tomatoes-accept.md
··· 1 + --- 2 + '@urql/exchange-graphcache': patch 3 + '@urql/exchange-populate': patch 4 + --- 5 + 6 + Remove the shared package, this will fix the types file generation for graphcache.
+1
exchanges/graphcache/src/ast/index.ts
··· 1 1 export { getFieldArguments, normalizeVariables } from './variables'; 2 2 export * from './traversal'; 3 3 export * from './schemaPredicates'; 4 + export * from './node';
+1 -1
exchanges/graphcache/src/ast/schemaPredicates.ts
··· 9 9 GraphQLUnionType, 10 10 } from 'graphql'; 11 11 12 - import { warn, invariant } from 'shared'; 12 + import { warn, invariant } from '../helpers/help'; 13 13 14 14 export const isFieldNullable = ( 15 15 schema: GraphQLSchema,
+1 -1
exchanges/graphcache/src/ast/traversal.test.ts
··· 1 1 import gql from 'graphql-tag'; 2 - import { getSelectionSet } from 'shared'; 2 + import { getSelectionSet } from './node'; 3 3 4 4 import { getMainOperation, shouldInclude } from './traversal'; 5 5
+3 -1
exchanges/graphcache/src/ast/traversal.ts
··· 7 7 valueFromASTUntyped, 8 8 Kind, 9 9 } from 'graphql'; 10 - import { invariant, getName } from 'shared'; 11 10 11 + import { getName } from './node'; 12 + 13 + import { invariant } from '../helpers/help'; 12 14 import { Fragments, Variables } from '../types'; 13 15 14 16 const isFragmentNode = (node: DefinitionNode): node is FragmentDefinitionNode =>
+2 -1
exchanges/graphcache/src/ast/variables.ts
··· 3 3 OperationDefinitionNode, 4 4 valueFromASTUntyped, 5 5 } from 'graphql'; 6 - import { getName } from 'shared'; 6 + 7 + import { getName } from './node'; 7 8 8 9 import { makeDict } from '../helpers/dict'; 9 10 import { Variables } from '../types';
+1 -1
exchanges/graphcache/src/operations/invalidate.ts
··· 1 1 import { FieldNode } from 'graphql'; 2 - import { getSelectionSet, getName, SelectionSet } from 'shared'; 2 + import { getSelectionSet, getName, SelectionSet } from '../ast/node'; 3 3 4 4 import { 5 5 getMainOperation,
+2 -3
exchanges/graphcache/src/operations/query.ts
··· 5 5 SelectionSet, 6 6 getFragmentTypeName, 7 7 getFieldAlias, 8 - warn, 9 - pushDebugNode, 10 - } from 'shared'; 8 + } from '../ast'; 9 + import { warn, pushDebugNode } from '../helpers/help'; 11 10 12 11 import { 13 12 getFragments,
+2 -3
exchanges/graphcache/src/operations/shared.ts
··· 1 1 import { FieldNode, InlineFragmentNode, FragmentDefinitionNode } from 'graphql'; 2 2 import { 3 - warn, 4 - pushDebugNode, 5 3 isInlineFragment, 6 4 getTypeCondition, 7 5 getSelectionSet, 8 6 getName, 9 7 SelectionSet, 10 8 isFieldNode, 11 - } from 'shared'; 9 + } from '../ast'; 10 + import { warn, pushDebugNode } from '../helpers/help'; 12 11 13 12 import { hasField } from '../store/data'; 14 13 import { Store, keyOfField } from '../store';
+3 -6
exchanges/graphcache/src/operations/write.ts
··· 6 6 normalizeVariables, 7 7 getFieldArguments, 8 8 isFieldAvailableOnType, 9 - } from '../ast'; 10 - import { 11 9 getSelectionSet, 12 10 getName, 13 11 SelectionSet, 14 12 getFragmentTypeName, 15 13 getFieldAlias, 16 - invariant, 17 - warn, 18 - pushDebugNode, 19 - } from 'shared'; 14 + } from '../ast'; 15 + 16 + import { invariant, warn, pushDebugNode } from '../helpers/help'; 20 17 21 18 import { 22 19 NullArray,
+1 -1
exchanges/graphcache/src/store/data.ts
··· 7 7 } from '../types'; 8 8 9 9 import { makeDict } from '../helpers/dict'; 10 - import { invariant, currentDebugStack } from 'shared'; 10 + import { invariant, currentDebugStack } from '../helpers/help'; 11 11 import { fieldInfoOfKey, joinKeys, prefixKey } from './keys'; 12 12 import { defer } from './timing'; 13 13
+1 -1
exchanges/graphcache/src/store/store.ts
··· 20 20 KeyingConfig, 21 21 DataFields, 22 22 } from '../types'; 23 - import { invariant } from 'shared'; 23 + import { invariant } from '../helpers/help'; 24 24 25 25 import { read, readFragment } from '../operations/query'; 26 26 import { writeFragment, startWrite } from '../operations/write';
+1 -2
exchanges/graphcache/tsconfig.json
··· 7 7 "paths": { 8 8 "urql": ["../../node_modules/urql/src"], 9 9 "*-urql": ["../../node_modules/*-urql/src"], 10 - "@urql/*": ["../../node_modules/@urql/*/src"], 11 - "shared": ["../../node_modules/shared/src"] 10 + "@urql/*": ["../../node_modules/@urql/*/src"] 12 11 } 13 12 } 14 13 }
+48
exchanges/populate/src/helpers/help.ts
··· 1 + // These are guards that are used throughout the codebase to warn or error on 2 + // unexpected behaviour or conditions. 3 + // Every warning and error comes with a number that uniquely identifies them. 4 + // You can read more about the messages themselves in `docs/help.md` 5 + export type ErrorCode = 6 + | 1 7 + | 2 8 + | 3 9 + | 4 10 + | 5 11 + | 6 12 + | 7 13 + | 8 14 + | 9 15 + | 10 16 + | 11 17 + | 12 18 + | 13 19 + | 15 20 + | 16 21 + | 17 22 + | 18 23 + | 19; 24 + 25 + const helpUrl = 26 + '\nhttps://github.com/FormidableLabs/urql/tree/master/exchanges/graphcache/help.md#'; 27 + const cache = new Set<string>(); 28 + 29 + export function invariant( 30 + condition: any, 31 + message: string, 32 + code: ErrorCode 33 + ): asserts condition { 34 + if (!condition) { 35 + const errorMessage = message || 'Minfied Error #' + code + '\n'; 36 + 37 + const error = new Error(errorMessage + helpUrl + code); 38 + error.name = 'Graphcache Error'; 39 + throw error; 40 + } 41 + } 42 + 43 + export function warn(message: string, code: ErrorCode) { 44 + if (!cache.has(message)) { 45 + console.warn(message + helpUrl + code); 46 + cache.add(message); 47 + } 48 + }
+30
exchanges/populate/src/helpers/node.ts
··· 1 + import { 2 + NameNode, 3 + SelectionNode, 4 + SelectionSetNode, 5 + GraphQLOutputType, 6 + isWrappingType, 7 + GraphQLWrappingType, 8 + } from 'graphql'; 9 + 10 + export type SelectionSet = ReadonlyArray<SelectionNode>; 11 + export type GraphQLFlatType = Exclude<GraphQLOutputType, GraphQLWrappingType>; 12 + 13 + /** Returns the name of a given node */ 14 + export const getName = (node: { name: NameNode }): string => node.name.value; 15 + 16 + /** Returns the SelectionSet for a given inline or defined fragment node */ 17 + export const getSelectionSet = (node: { 18 + selectionSet?: SelectionSetNode; 19 + }): SelectionSet => 20 + node.selectionSet !== undefined ? node.selectionSet.selections : []; 21 + 22 + export const unwrapType = ( 23 + type: null | undefined | GraphQLOutputType 24 + ): GraphQLFlatType | null => { 25 + if (isWrappingType(type)) { 26 + return unwrapType(type.ofType); 27 + } 28 + 29 + return type || null; 30 + };
+2 -1
exchanges/populate/src/populateExchange.ts
··· 14 14 Kind, 15 15 visit, 16 16 } from 'graphql'; 17 - import { getName, getSelectionSet, unwrapType, invariant, warn } from 'shared'; 17 + import { getName, getSelectionSet, unwrapType } from './helpers/node'; 18 + import { invariant, warn } from './helpers/help'; 18 19 19 20 import { pipe, tap, map } from 'wonka'; 20 21 import { Exchange, Operation } from '@urql/core';
+1 -2
exchanges/populate/tsconfig.json
··· 7 7 "paths": { 8 8 "urql": ["../../node_modules/urql/src"], 9 9 "*-urql": ["../../node_modules/*-urql/src"], 10 - "@urql/*": ["../../node_modules/@urql/*/src"], 11 - "shared": ["../../node_modules/shared/src"] 10 + "@urql/*": ["../../node_modules/@urql/*/src"] 12 11 } 13 12 } 14 13 }
-11
exchanges/shared/package.json
··· 1 - { 2 - "private": true, 3 - "name": "shared", 4 - "version": "1.0.0", 5 - "scripts": { 6 - "build": "echo 'not building shared'" 7 - }, 8 - "jest": { 9 - "preset": "../../scripts/jest/preset" 10 - } 11 - }
-1
exchanges/shared/src/ast/index.ts
··· 1 - export * from './node';
exchanges/shared/src/ast/node.test.ts exchanges/graphcache/src/ast/node.test.ts
exchanges/shared/src/ast/node.ts exchanges/graphcache/src/ast/node.ts
exchanges/shared/src/helpers/help.ts exchanges/graphcache/src/helpers/help.ts
-1
exchanges/shared/src/helpers/index.ts
··· 1 - export * from './help';
-2
exchanges/shared/src/index.ts
··· 1 - export * from './ast'; 2 - export * from './helpers';
-12
exchanges/shared/tsconfig.json
··· 1 - { 2 - "extends": "../../tsconfig.json", 3 - "include": ["src"], 4 - "compilerOptions": { 5 - "baseUrl": "./", 6 - "paths": { 7 - "urql": ["../../node_modules/urql/src"], 8 - "*-urql": ["../../node_modules/*-urql/src"], 9 - "@urql/*": ["../../node_modules/@urql/*/src"] 10 - } 11 - } 12 - }
-1
scripts/jest/preset.js
··· 10 10 "^urql$": "<rootDir>/../../node_modules/urql/src", 11 11 "^(.*-urql)$": "<rootDir>/../../node_modules/$1/src", 12 12 "^@urql/(.*)$": "<rootDir>/../../node_modules/@urql/$1/src", 13 - "^shared$": "<rootDir>/../../node_modules/shared/src", 14 13 }, 15 14 watchPlugins: ['jest-watch-yarn-workspaces'], 16 15 testRegex: '(src/.*(\\.|/)(test|spec))\\.tsx?$',
+1 -2
tsconfig.json
··· 5 5 "urql": ["packages/react-urql/src"], 6 6 "*-urql": ["packages/*-urql/src"], 7 7 "@urql/exchange-*": ["exchanges/*/src"], 8 - "@urql/*": ["packages/*-urql/src", "packages/*/src"], 9 - "shared": ["exchanges/shared/src"] 8 + "@urql/*": ["packages/*-urql/src", "packages/*/src"] 10 9 }, 11 10 "esModuleInterop": true, 12 11 "forceConsistentCasingInFileNames": true,