Skip to content

Instantly share code, notes, and snippets.

View chsami's full-sized avatar

chsami chsami

View GitHub Profile
//This code is needed to support recursion
_fixture.Behaviors.OfType<ThrowingRecursionBehavior>().ToList()
.ForEach(b => _fixture.Behaviors.Remove(b));
_fixture.Behaviors.Add(new OmitOnRecursionBehavior(1));
public class Person {
List<Person> Friends { get; set;}
}
_fixture.Customizations.Add(
new TypeRelay(
typeof(Animal),
typeof(Dog)));
_fixture.Customizations.Add(
new TypeRelay(
typeof(Animal),
typeof(Cat)));
_fixture.Register<Animal>(() => null);
_fixture.Customizations.Add(
new TypeRelay(
typeof(Animal),
typeof(Dog)));
_fixture.Customizations.Add(
new TypeRelay(
typeof(Animal),
typeof(Cat)));
import {Injectable} from '@angular/core';
import {ApolloLink, Observable} from 'apollo-link';
import {Apollo} from 'apollo-angular';
import {HttpLink} from 'apollo-angular-link-http';
import {withClientState} from 'apollo-link-state';
import {onError} from 'apollo-link-error';
import {InMemoryCache} from 'apollo-cache-inmemory';
import {PresetConfig} from './types';
constructor(apollo: Apollo, httpLink: HttpLink, oAuthService: OAuthService) {
apollo.create({
link: httpLink.create({
uri: environment.graphqlurl,
headers: new HttpHeaders({
authorization: oAuthService.getAccessToken()
}),
withCredentials: true
}),
cache
{
provide: APOLLO_OPTIONS,
useFactory(httpLink: HttpLink) {
return {
cache, // InMemoryCache with custom fragment matcher
link: httpLink.create({
uri: environment.targetsugraphqlurl
})
};
},
import introspectionResult from '../introspection-result';
const fragmentMatcher = new IntrospectionFragmentMatcher({
introspectionQueryResultData: introspectionResult
});
const cache = new InMemoryCache({
fragmentMatcher
./src/introspection-result.ts:
plugins:
- fragment-matcher