Skip to content

Commit

Permalink
use underscored props
Browse files Browse the repository at this point in the history
  • Loading branch information
JoviDeCroock committed Jul 19, 2023
1 parent 0c45c9a commit 6f58479
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 13 deletions.
4 changes: 2 additions & 2 deletions exchanges/graphcache/src/cacheExchange.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -691,7 +691,7 @@ describe('directives', () => {
todos {
id
text
completed @optional
completed @_optional
}
}
`;
Expand Down Expand Up @@ -763,7 +763,7 @@ describe('directives', () => {
todos {
id
text
completed @required
completed @_required
}
}
`;
Expand Down
1 change: 0 additions & 1 deletion exchanges/graphcache/src/cacheExchange.ts
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,6 @@ export const cacheExchange =
operations.set(operation.key, operation);
updateDependencies(operation, result.dependencies);

// TODO: remove directives before sending it on
return {
outcome: cacheOutcome,
operation,
Expand Down
2 changes: 1 addition & 1 deletion exchanges/graphcache/src/extras/relayPagination.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1542,7 +1542,7 @@ describe('as directive', () => {
const Pagination = gql`
query ($cursor: String) {
__typename
items(first: 1, after: $cursor) @relayPagination {
items(first: 1, after: $cursor) @_relayPagination {
__typename
edges {
__typename
Expand Down
2 changes: 1 addition & 1 deletion exchanges/graphcache/src/extras/simplePagination.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -443,7 +443,7 @@ describe('as directive', () => {
const Pagination = gql`
query ($skip: Number, $limit: Number) {
__typename
persons(skip: $skip, limit: $limit) @simplePagination {
persons(skip: $skip, limit: $limit) @_simplePagination {
__typename
id
name
Expand Down
9 changes: 3 additions & 6 deletions exchanges/graphcache/src/operations/query.ts
Original file line number Diff line number Diff line change
Expand Up @@ -356,8 +356,8 @@ const readSelection = (
let node: FormattedNode<FieldNode> | void;
const output = InMemoryData.makeData(input);
while ((node = iterate()) !== undefined) {
const fieldDirectives = node.directives?.map(x => x.name.value);
const storeDirective = fieldDirectives?.find(x => store.directives[x]);
const fieldDirectives = Object.keys(node._directives || {}).map(x => x);
const storeDirective = fieldDirectives.find(x => store.directives[x]);

// Derive the needed data from our node.
const fieldName = getName(node);
Expand Down Expand Up @@ -415,9 +415,7 @@ const readSelection = (
}

if (storeDirective) {
const fieldDirective = node.directives!.find(
x => x.name.value === storeDirective
)!;
const fieldDirective = node._directives![storeDirective];
const directiveArguments =
getFieldArguments(fieldDirective, ctx.variables) || {};
dataFieldValue = store.directives[storeDirective]!(
Expand Down Expand Up @@ -448,7 +446,6 @@ const readSelection = (
if (
store.schema &&
dataFieldValue === null &&
// TODO: how would we inform this that we are indeed dealing with a nullable field
!isFieldNullable(store.schema, typename, fieldName)
) {
// Special case for when null is not a valid value for the
Expand Down
10 changes: 8 additions & 2 deletions exchanges/graphcache/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -555,7 +555,14 @@ export type CacheExchangeOpts = {
* @see {@link https://urql.dev/goto/docs/graphcache/local-resolvers} for the full resolvers docs.
*/
resolvers?: ResolverConfig;
// TODO: docs
/** Configures directives which can perform custom logic on fields.
*
* @remarks
* `directives` is a map of a directive-name to a function which will be executed
* when graphcache encounters this directive.
*
* @see {@link https://urql.dev/goto/docs/graphcache/local-directives} for the full directives docs.
*/
directives?: DirectivesConfig;
/** Configures optimistic updates to react to mutations instantly before an API response.
*
Expand Down Expand Up @@ -708,7 +715,6 @@ export type ResolverConfig = {
} | void;
};

// TODO: docs
export type DirectivesConfig = {
[directiveName: string]: Directive;
};
Expand Down

0 comments on commit 6f58479

Please sign in to comment.