Skip to content

Commit

Permalink
(graphcache) - Mute warnings when using built-in fields (#919)
Browse files Browse the repository at this point in the history
  • Loading branch information
kitten authored Jul 21, 2020
1 parent 25624a7 commit ac64214
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .changeset/chatty-poems-rescue.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@urql/exchange-graphcache': patch
---

Mute warning when using built-in GraphQL fields, like `__type`
6 changes: 4 additions & 2 deletions exchanges/graphcache/src/ast/schemaPredicates.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,14 @@ import {
OptimisticMutationConfig,
} from '../types';

const BUILTIN_FIELD_RE = /^__/;

export const isFieldNullable = (
schema: GraphQLSchema,
typename: string,
fieldName: string
): boolean => {
if (fieldName === '__schema') return true;
if (BUILTIN_FIELD_RE.test(fieldName)) return true;
const field = getField(schema, typename, fieldName);
return !!field && isNullableType(field.type);
};
Expand All @@ -43,7 +45,7 @@ export const isFieldAvailableOnType = (
typename: string,
fieldName: string
): boolean => {
if (fieldName === '__schema') return true;
if (BUILTIN_FIELD_RE.test(fieldName)) return true;
return !!getField(schema, typename, fieldName);
};

Expand Down

0 comments on commit ac64214

Please sign in to comment.