Skip to content
Permalink
Browse files

fix(deps): fix usage of apollo for the new version

  • Loading branch information...
anehx committed Jul 24, 2019
1 parent dcbbf9f commit 6ec5842843dc1f600e94c2b1c1c7bab4afe158ca
@@ -3,18 +3,16 @@ import Component from "@ember/component";
import layout from "../templates/components/cf-field-value";
import { computed } from "@ember/object";
import { camelize } from "@ember/string";
import { inject as service } from "@ember/service";
import { ComponentQueryManager } from "ember-apollo-client";
import getFileAnswerInfoQuery from "ember-caluma/gql/queries/get-fileanswer-info";

function getOptionKey(questionType) {
return `${camelize(questionType.replace(/Question$/, ""))}Options`;
}

export default Component.extend({
export default Component.extend(ComponentQueryManager, {
layout,

apollo: service(),

tagName: "span",

value: computed("field.answer.value", function() {
@@ -2,16 +2,16 @@ import Component from "@ember/component";
import { computed } from "@ember/object";
import { reads } from "@ember/object/computed";
import { inject as service } from "@ember/service";
import { ComponentQueryManager } from "ember-apollo-client";

import getFileAnswerInfoQuery from "ember-caluma/gql/queries/get-fileanswer-info";
import layout from "../../../templates/components/cf-field/input/file";

export default Component.extend({
export default Component.extend(ComponentQueryManager, {
layout,
tagName: "",

intl: service(),
apollo: service(),

downloadUrl: reads("field.answer.value.downloadUrl"),
downloadName: reads("field.answer.value.name"),
@@ -8,6 +8,7 @@ import { camelize } from "@ember/string";
import { task } from "ember-concurrency";
import { all, resolve } from "rsvp";
import { validate } from "ember-validators";
import { ObjectQueryManager } from "ember-apollo-client";

import Answer from "ember-caluma/lib/answer";
import Question from "ember-caluma/lib/question";
@@ -62,7 +63,7 @@ const getDependenciesFromJexl = expression => {
*
* @class Field
*/
export default Base.extend({
export default Base.extend(ObjectQueryManager, {
saveDocumentFloatAnswerMutation,
saveDocumentIntegerAnswerMutation,
saveDocumentStringAnswerMutation,
@@ -71,8 +72,6 @@ export default Base.extend({
saveDocumentDateAnswerMutation,
saveDocumentTableAnswerMutation,

apollo: service(),

intl: service(),

calumaStore: service(),
@@ -1,4 +1,3 @@
import { computed } from "@ember/object";
import Mixin from "@ember/object/mixin";
import { inject as service } from "@ember/service";
import {
@@ -12,33 +11,32 @@ import introspectionQueryResultData from "ember-caluma/-private/fragment-types";
export default Mixin.create({
intl: service(),

cache: computed(
() =>
new InMemoryCache({
fragmentMatcher: new IntrospectionFragmentMatcher({
introspectionQueryResultData
}),
dataIdFromObject: obj => {
if (obj.slug) {
obj = Object.assign({}, obj, { _id: obj.slug });
}

return defaultDataIdFromObject(obj);
cache() {
return new InMemoryCache({
fragmentMatcher: new IntrospectionFragmentMatcher({
introspectionQueryResultData
}),
dataIdFromObject: obj => {
if (obj.slug) {
obj = Object.assign({}, obj, { _id: obj.slug });
}
})
),
return defaultDataIdFromObject(obj);
}
});
},

link: computed(function() {
link() {
let httpLink = this._super(...arguments);

let localeLink = setContext((_, { headers }) => ({
let localeLink = setContext((request, context) => ({
...context,
headers: {
...headers,
...context.headers,
language: this.get("intl.locale"),
"accept-language": this.get("intl.locale")
}
}));

return localeLink.concat(httpLink);
})
}
});
@@ -30,11 +30,12 @@
"ember-apollo-client: https://github.com/bgentry/ember-apollo-client/issues/279"
],
"dependencies": {
"apollo-link-context": "^1.0.17",
"apollo-cache-inmemory": "^1.6.2",
"apollo-link-context": "^1.0.18",
"broccoli-funnel": "^2.0.2",
"broccoli-merge-trees": "^3.0.2",
"ember-apollo-client": "2.0.0-beta.4",
"ember-auto-import": "^1.3.0",
"ember-auto-import": "^1.5.2",
"ember-changeset": "^2.1.0",
"ember-changeset-validations": "^2.1.0",
"ember-cli-babel": "^7.7.3",
@@ -7,8 +7,6 @@ import { decodeId } from "ember-caluma/helpers/decode-id";
import ENV from "ember-caluma/config/environment";

export default Route.extend(RouteQueryManager, {
apollo: service(),

intl: service(),
calumaOptions: service(),

@@ -20,21 +20,22 @@ module("Unit | Mixin | caluma-apollo-service-mixin", function(hooks) {

let subject = CalumaApolloServiceMixinObject.create();

assert.ok(subject.get("cache") instanceof InMemoryCache);
const cache = subject.cache();

assert.ok(cache instanceof InMemoryCache);
assert.ok(
subject.get("cache.config.fragmentMatcher") instanceof
IntrospectionFragmentMatcher
cache.config.fragmentMatcher instanceof IntrospectionFragmentMatcher
);

assert.deepEqual(
subject.get("cache.config.fragmentMatcher.possibleTypesMap.Node"),
cache.config.fragmentMatcher.possibleTypesMap.Node,
introspectionQueryResultData.__schema.types
.find(({ name }) => name === "Node")
.possibleTypes.map(({ name }) => name)
);

assert.deepEqual(
subject.get("cache.config.fragmentMatcher.possibleTypesMap.Answer"),
cache.config.fragmentMatcher.possibleTypesMap.Answer,
introspectionQueryResultData.__schema.types
.find(({ name }) => name === "Answer")
.possibleTypes.map(({ name }) => name)
@@ -50,16 +51,18 @@ module("Unit | Mixin | caluma-apollo-service-mixin", function(hooks) {

let subject = CalumaApolloServiceMixinObject.create();

const cache = subject.cache();

assert.equal(
subject.get("cache.config.dataIdFromObject")({
cache.config.dataIdFromObject({
slug: "test",
__typename: "TestType"
}),
"TestType:test"
);

assert.equal(
subject.get("cache.config.dataIdFromObject")({
cache.config.dataIdFromObject({
edges: [
{
node: {
@@ -2135,7 +2135,7 @@ aot-test-generators@^0.1.0:
dependencies:
jsesc "^2.5.0"

apollo-cache-inmemory@^1.3.11:
apollo-cache-inmemory@^1.3.11, apollo-cache-inmemory@^1.6.2:
version "1.6.2"
resolved "https://registry.yarnpkg.com/apollo-cache-inmemory/-/apollo-cache-inmemory-1.6.2.tgz#bbf2e4e1eacdf82b2d526f5c2f3b37e5acee3c5e"
integrity sha512-AyCl3PGFv5Qv1w4N9vlg63GBPHXgMCekZy5mhlS042ji0GW84uTySX+r3F61ZX3+KM1vA4m9hQyctrEGiv5XjQ==
@@ -2248,7 +2248,7 @@ apollo-codegen@^0.20.2:
source-map-support "^0.5.0"
yargs "^10.0.3"

apollo-link-context@^1.0.17:
apollo-link-context@^1.0.17, apollo-link-context@^1.0.18:
version "1.0.18"
resolved "https://registry.yarnpkg.com/apollo-link-context/-/apollo-link-context-1.0.18.tgz#9e700e3314da8ded50057fee0a18af2bfcedbfc3"
integrity sha512-aG5cbUp1zqOHHQjAJXG7n/izeMQ6LApd/whEF5z6qZp5ATvcyfSNkCfy3KRJMMZZ3iNfVTs6jF+IUA8Zvf+zeg==
@@ -6189,7 +6189,7 @@ ember-assign-polyfill@^2.5.0, ember-assign-polyfill@^2.6.0:
ember-cli-babel "^6.16.0"
ember-cli-version-checker "^2.0.0"

ember-auto-import@^1.2.13, ember-auto-import@^1.2.19, ember-auto-import@^1.3.0, ember-auto-import@^1.4.0, ember-auto-import@^1.4.1:
ember-auto-import@^1.2.13, ember-auto-import@^1.2.19, ember-auto-import@^1.4.0, ember-auto-import@^1.4.1, ember-auto-import@^1.5.2:
version "1.5.2"
resolved "https://registry.yarnpkg.com/ember-auto-import/-/ember-auto-import-1.5.2.tgz#e97ed96b600caa6090ffed83e4611c3e7ec9bad7"
integrity sha512-skVQpfdc6G5OVRsyemDn3vI1nj/iBBgnoqRLRka0ZbDT2GqelmyJ86bp+Bd/ztJe45Le3we+LXbR7T54RU5A9w==
@@ -7802,7 +7802,7 @@ eslint-scope@3.7.1:
esrecurse "^4.1.0"
estraverse "^4.1.1"

eslint-scope@^4.0.0:
eslint-scope@^4.0.0, eslint-scope@^4.0.3:
version "4.0.3"
resolved "https://registry.yarnpkg.com/eslint-scope/-/eslint-scope-4.0.3.tgz#ca03833310f6889a3264781aa82e63eb9cfe7848"
integrity sha512-p7VutNr1O/QrxysMo3E45FjYDTeXBy0iTltPFNSqKAIfjDSXC+4dj+qfyuD8bfAXrW/y6lW3O76VaYNPKfpKrg==
@@ -9975,7 +9975,7 @@ inquirer@^3.3.0:
strip-ansi "^4.0.0"
through "^2.3.6"

inquirer@^6, inquirer@^6.2.0, inquirer@^6.4.1:
inquirer@^6, inquirer@^6.2.0, inquirer@^6.2.2, inquirer@^6.4.1:
version "6.5.0"
resolved "https://registry.yarnpkg.com/inquirer/-/inquirer-6.5.0.tgz#2303317efc9a4ea7ec2e2df6f86569b734accf42"
integrity sha512-scfHejeG/lVZSpvCXpsB4j/wQNPM5JC8kiElOI0OUTwmc1RTpXr4H32/HOlQHcZiYl2z2VElwuCVDRG8vFmbnA==
resolved "https://registry.yarnpkg.com/strip-indent/-/strip-indent-2.0.0.tgz#5ef8db295d01e6ed6cbf7aab96998d7822527b68"
integrity sha1-XvjbKV0B5u1sv3qrlpmNeCJSe2g=

strip-json-comments@2.0.1, strip-json-comments@~2.0.1:
strip-json-comments@2.0.1, strip-json-comments@^2.0.1, strip-json-comments@~2.0.1:
version "2.0.1"
resolved "https://registry.yarnpkg.com/strip-json-comments/-/strip-json-comments-2.0.1.tgz#3c531942e908c2697c0ec344858c286c7ca0a60a"
integrity sha1-PFMZQukIwml8DsNEhYwobHygpgo=

0 comments on commit 6ec5842

Please sign in to comment.
You can’t perform that action at this time.