Skip to content

Commit

Permalink
fix(performance): improve loading performance and caching
Browse files Browse the repository at this point in the history
  • Loading branch information
Jonas Metzener authored and czosel committed Jul 19, 2019
1 parent a15161a commit 7bcedab
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 15 deletions.
8 changes: 4 additions & 4 deletions addon/components/cf-content.js
Original file line number Diff line number Diff line change
Expand Up @@ -143,19 +143,19 @@ export default Component.extend(ComponentQueryManager, {
"allDocuments.edges"
)).map(({ node }) => node);

const [formDocument] = (yield this.apollo.query(
const [form] = (yield this.apollo.query(
{
query: getDocumentFormsQuery,
networkPolicy: "cache-first",
variables: { id: this.documentId }
variables: { slug: answerDocument.form.slug }
},
"allDocuments.edges"
"allForms.edges"
)).map(({ node }) => node);

this.calumaStore.clear();

return Document.create(getOwner(this).ownerInjection(), {
raw: parseDocument({ ...answerDocument, ...formDocument })
raw: parseDocument({ ...answerDocument, form })
});
})
});
3 changes: 3 additions & 0 deletions addon/gql/queries/get-document-answers.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ query($id: ID!) {
edges {
node {
id
form {
slug
}
answers {
edges {
node {
Expand Down
19 changes: 8 additions & 11 deletions addon/gql/queries/get-document-forms.graphql
Original file line number Diff line number Diff line change
@@ -1,18 +1,15 @@
#import 'ember-caluma/gql/fragments/field-question'

query($id: ID!) {
allDocuments(id: $id) {
query($slug: String!) {
allForms(slug: $slug) {
edges {
node {
id
form {
slug
name
questions {
edges {
node {
...FieldQuestion
}
slug
name
questions {
edges {
node {
...FieldQuestion
}
}
}
Expand Down

0 comments on commit 7bcedab

Please sign in to comment.