Skip to content

Commit

Permalink
fix(package/gqty): remove alias without args (#1476)
Browse files Browse the repository at this point in the history
  • Loading branch information
vicary committed Feb 1, 2023
1 parent 67553c2 commit 595ec84
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 14 deletions.
5 changes: 5 additions & 0 deletions .changeset/sour-rocks-vanish.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'gqty': patch
---

Remove alias without args
14 changes: 7 additions & 7 deletions packages/gqty/src/Accessor/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import {
import { Selection, SelectionType } from '../Selection';
import {
decycle,
isEmptyObject,
isInteger,
isObject,
isObjectWithType,
Expand Down Expand Up @@ -207,6 +208,8 @@ export function createAccessorCreators<
});
}

const args = dataOrArgs as Record<string, unknown>;

const resolveInfo = (
accessorOrSelection as Function & {
[ResolveInfoSymbol]?: ResolveInfo;
Expand All @@ -221,7 +224,7 @@ export function createAccessorCreators<

const selection = innerState.selectionManager.getSelection({
...resolveInfo,
args: dataOrArgs as Record<string, unknown>,
args: isEmptyObject(args) ? undefined : args,
});

const data = extractDataFromProxy(possibleData);
Expand Down Expand Up @@ -598,7 +601,7 @@ export function createAccessorCreators<
let { pureType, isArray } = parseSchemaType(__type);

const resolve = (args?: {
argValues: Record<string, unknown>;
argValues?: Record<string, unknown>;
argTypes: Record<string, string>;
}): unknown => {
const selection = innerState.selectionManager.getSelection({
Expand Down Expand Up @@ -696,9 +699,7 @@ export function createAccessorCreators<
};

return Object.assign(
function ProxyFn(
argValues: Record<string, unknown> = emptyVariablesObject
) {
function ProxyFn(argValues?: Record<string, unknown>) {
return resolve({
argValues,
argTypes: __args,
Expand All @@ -715,6 +716,7 @@ export function createAccessorCreators<
});
}
);

return accessor;
}

Expand Down Expand Up @@ -794,5 +796,3 @@ export function createAccessorCreators<
subscription,
};
}

const emptyVariablesObject = {};
8 changes: 1 addition & 7 deletions packages/gqty/test/accessor.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -398,13 +398,7 @@ describe('mutate accessors', () => {
test('works', async () => {
const { query, setCache, resolved } = await createTestClient();

setCache(
query.human,
{},
{
name: 'hello',
}
);
setCache(query.human, {}, { name: 'hello' });

const humanHello = query.human();

Expand Down

1 comment on commit 595ec84

@vercel
Copy link

@vercel vercel bot commented on 595ec84 Feb 1, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

gqty – ./

gqty.vercel.app
gqty-gqty.vercel.app
gqty.dev
gqty-git-main-gqty.vercel.app
www.gqty.dev

Please sign in to comment.