This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type User { | |
id: String! | |
name: String @deprecated(reason: "Use firstname instead.") | |
firstname: String | |
age: Int | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { makeExecutableSchema } from 'graphql-tools' | |
import merge from 'lodash.merge' | |
import { | |
queries as fooQueries, | |
resolvers as fooResolvers, | |
typeDefinitions as fooTypeDefinitions, | |
} from './foo/schema' | |
import { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { mergeSchemas } from 'graphql-tools' | |
import fooSchema from './foo' // export default makeExecutableSchema({ typeDefs: fooTypeDefinitions }) | |
import barSchema from './bar' // export default makeExecutableSchema({ typeDefs: barTypeDefinitions }) | |
export default mergeSchemas({ | |
schemas: [fooSchema, barSchema], | |
}) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export const typeDefinitions = ` | |
type Foo { | |
bar: String | |
baz: String | |
} | |
` |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if ('serviceWorker' in navigator) { | |
window.addEventListener('load', () => { | |
navigator.serviceWorker.register("/service-worker.js").then(register => { | |
console.log('Register succeeded in scope : ', register.scope) | |
}) | |
}) | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const VERSION = '1' | |
const CACHE_KEY = `cache-v${VERSION}` | |
const assetsToCache = [ | |
'/', | |
'/assets/css/app.css', | |
'/assets/js/app.js', | |
'/assets/images/icons/icon-16x16.png', | |
'/assets/images/icons/icon-24x24.png', | |
'/assets/images/icons/icon-36x36.png', | |
'/assets/images/icons/icon-64x64.png', |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
self.addEventListener('fetch', event => { | |
event.respondWith( | |
caches.match(event.request).then(cacheResp => { | |
return cacheResp || fetch(event.request).then(response => { | |
return caches.open(CACHE_KEY).then(cache => { | |
cache.put(event.request, response.clone()) | |
return response | |
}) | |
}) | |
}) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
self.addEventListener('activate', event => { | |
const cacheWhitelist = [CACHE_KEY] | |
event.waitUntil( | |
caches.keys().then(keyList => { | |
return Promise.all(keyList.map(function(key) { | |
if (cacheWhitelist.indexOf(key) === -1) { | |
return caches.delete(key) | |
} | |
})) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { GraphQLString, GraphQLNonNull } from 'graphql' | |
import { expect } from 'chai' | |
import rootSchema from '../../src/schemas/rootSchema' | |
describe('Test schema', () => { | |
it('has correct character schema', () => { | |
const characterSchema = rootSchema.getTypeMap().Character.getFields() | |
expect(characterSchema).to.have.property('name') | |
expect(characterSchema.name.type).to.deep.equals(GraphQLString) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { expect } from 'chai' | |
import rootSchema from '../../src/schemas/rootSchema' | |
describe('Test resolvers', () => { | |
it('has correct getCharacters query', (done) => { | |
const charactersQuery = rootSchema.getTypeMap().Query.getFields().getCharacters | |
const expected = [ | |
{ id: '1', name: 'John Snow', gender: { name: 'Male' }} | |
] |