Skip to content

Commit

Permalink
fix(schema): fix edge and node type names
Browse files Browse the repository at this point in the history
  • Loading branch information
tothandras committed Nov 1, 2015
1 parent bd09316 commit 736fed4
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/schema/schema.js
Original file line number Diff line number Diff line change
Expand Up @@ -117,20 +117,24 @@ function getMutationField(graffitiModel, type, viewer) {
type: new GraphQLList(GraphQLID)
};
}

// TODO support objects
// else {
// args = {...args, ...field.type._typeConfig.fields()};
// }
}

if (!(field.type instanceof GraphQLObjectType) && field.name !== 'id' && !field.name.startsWith('_')) {
inputFields[field.name] = field;
}

return inputFields;
}, {});

const Name = name[0].toUpperCase() + name.slice(1);
const changedName = `changed${Name}`;
const edgeName = `${changedName}Edge`;
const nodeName = `${changedName}Node`;

const addName = `add${name}`;
const updateName = `update${name}`;
Expand All @@ -143,8 +147,8 @@ function getMutationField(graffitiModel, type, viewer) {
outputFields: {
viewer,
[edgeName]: {
type: connectionDefinitions({name: edgeName, nodeType: new GraphQLObjectType({
name: edgeName,
type: connectionDefinitions({name: changedName, nodeType: new GraphQLObjectType({
name: nodeName,
fields
})}).edgeType,
resolve: (node) => ({
Expand Down Expand Up @@ -189,7 +193,7 @@ function getMutationField(graffitiModel, type, viewer) {
};
}

function getFields(graffitiModels, {mutation} = {mutation: true}) {
function getFields(graffitiModels, {mutation = true} = {}) {
const types = getTypes(graffitiModels);

const viewer = {
Expand Down

0 comments on commit 736fed4

Please sign in to comment.