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.

add special case for fetching an introspection result in graphcache (#893)

authored by

Jovi De Croock and committed by
GitHub
ca68584a 1fe8e79a

+18 -2
+5
.changeset/afraid-dragons-train.md
··· 1 + --- 2 + '@urql/exchange-graphcache': patch 3 + --- 4 + 5 + Add special-case for fetching an introspection result in our schema-checking, this avoids an error when urql-devtools fetches the backend graphql schema.
+2
exchanges/graphcache/src/ast/schemaPredicates.ts
··· 22 22 typename: string, 23 23 fieldName: string 24 24 ): boolean => { 25 + if (fieldName === '__schema') return true; 25 26 const field = getField(schema, typename, fieldName); 26 27 return !!field && isNullableType(field.type); 27 28 }; ··· 42 43 typename: string, 43 44 fieldName: string 44 45 ): boolean => { 46 + if (fieldName === '__schema') return true; 45 47 return !!getField(schema, typename, fieldName); 46 48 }; 47 49
+11 -2
exchanges/graphcache/src/store/store.test.ts
··· 6 6 import * as InMemoryData from './data'; 7 7 import { Store } from './store'; 8 8 import { noop } from '../test-utils/utils'; 9 + import { getIntrospectionQuery, parse } from 'graphql'; 9 10 10 11 const Appointment = gql` 11 12 query appointment($id: String) { ··· 385 386 { 386 387 query: connection, 387 388 }, 388 - // @ts-ignore 389 389 { 390 390 exercisesConnection: null, 391 - } 391 + } as any 392 392 ); 393 393 let { data } = query(store, { query: connection }); 394 394 ··· 802 802 'Invalid optimistic mutation field: `deleteTodo` is not a mutation field in the defined schema, but the `optimistic` option is referencing it.' 803 803 ); 804 804 expect(warnMessage).toContain('https://bit.ly/2XbVrpR#24'); 805 + }); 806 + 807 + it('should not warn for an introspection result root', function () { 808 + // eslint-disable-next-line 809 + const schema = require('../test-utils/simple_schema.json'); 810 + const store = new Store({ schema }); 811 + 812 + query(store, { query: parse(getIntrospectionQuery()) }, schema); 813 + expect(console.warn).toBeCalledTimes(0); 805 814 }); 806 815 });