Skip to content
Permalink
Browse files

fix(mirage): update mirage schema and fix generic scalar type

  • Loading branch information...
anehx committed May 21, 2019
1 parent 3c2bf1d commit c1cdaa146e060b7c5794127150ed19132633839e
@@ -5,5 +5,5 @@ export default Factory.extend({
slug: i => `form-${i + 1}`,
description: () => faker.lorem.paragraph(),
isArchived: false,
meta: JSON.stringify({})
meta: () => ({})
});
@@ -3,5 +3,5 @@ import { Factory } from "ember-cli-mirage";
export default Factory.extend({
slug: i => `option-${i + 1}`,
label: i => `Option ${i + 1}`,
meta: JSON.stringify({})
meta: () => ({})
});
@@ -20,7 +20,7 @@ export default Factory.extend({
isRequired: () => faker.random.boolean().toString(),
isHidden: "false",
isArchived: false,
meta: JSON.stringify({}),
meta: () => ({}),

afterCreate(question, server) {
if (["TEXT", "TEXTAREA"].includes(question.type)) {
@@ -15,10 +15,7 @@ export default {
name: "Document"
},
{
name: "FileAnswer"
},
{
name: "File"
name: "FormAnswer"
},
{
name: "Case"
@@ -90,7 +87,10 @@ export default {
name: "TableAnswer"
},
{
name: "FormAnswer"
name: "FileAnswer"
},
{
name: "File"
},
{
name: "SimpleTask"
@@ -168,7 +168,7 @@ export default {
name: "Answer",
possibleTypes: [
{
name: "FileAnswer"
name: "FormAnswer"
},
{
name: "StringAnswer"
@@ -189,7 +189,7 @@ export default {
name: "TableAnswer"
},
{
name: "FormAnswer"
name: "FileAnswer"
}
]
}
@@ -27,8 +27,8 @@ export default function(server) {
schema,
mocks: {
...mocks,
JSONString: () => '{"foo": "bar"}',
GenericScalar: value => value,
JSONString: () => JSON.stringify({}),
GenericScalar: () => ({}),
Node: (_, { id }) => ({ __typename: atob(id).split(":")[0] })
},
preserveResolvers: false
@@ -1,5 +1,15 @@
import { GraphQLDateTime } from "graphql-iso-date";

export default {
DateTime: GraphQLDateTime
DateTime: GraphQLDateTime,
// generic scalar serializes from a string to an object but deserializes as
// object for some reason ¯\_(ツ)_/¯. But hey, it works!
GenericScalar: {
serialize(str) {
return typeof str === "string" ? JSON.parse(str) : str;
},
deserialize(obj) {
return obj;
}
}
};

0 comments on commit c1cdaa1

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