Skip to content

Commit c273bdb

Browse files
authored
Merge pull request #43 from kbaumzie/master
feat: add description property to type
2 parents 4ec2b16 + 78a0f8d commit c273bdb

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

src/converter.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ function getObjectFields (context, schema, typeName, buildingInputType) {
100100
const type = mapType(context, attributeDefinition, qualifiedAttributeName, buildingInputType);
101101

102102
const modifiedType = includes(schema.required, attributeName) ? GraphQLNonNull(type) : type;
103-
return { type: modifiedType };
103+
return { type: modifiedType, description: attributeDefinition.description };
104104
}),
105105
{ type: DROP_ATTRIBUTE_MARKER }
106106
);
@@ -124,11 +124,13 @@ function mapType (context, attributeDefinition, attributeName, buildingInputType
124124
return buildingInputType
125125
? new GraphQLInputObjectType({
126126
name,
127-
fields: () => getObjectFields(context, attributeDefinition, attributeName, buildingInputType)
127+
fields: () => getObjectFields(context, attributeDefinition, attributeName, buildingInputType),
128+
description: attributeDefinition.description
128129
})
129130
: new GraphQLObjectType({
130131
name,
131-
fields: () => getObjectFields(context, attributeDefinition, attributeName, buildingInputType)
132+
fields: () => getObjectFields(context, attributeDefinition, attributeName, buildingInputType),
133+
description: attributeDefinition.description
132134
});
133135
// return objectFromSchema(context, attributeDefinition, attributeName, buildingInputType);
134136
}

test/converter.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,13 +112,16 @@ async function testAttrbuteType (test, jsonType, graphQLType, options) {
112112
type: 'object',
113113
properties: {
114114
attribute: { type: jsonType }
115-
}
115+
},
116+
description: 'Description'
116117
};
117118

118119
const expectedType = `
120+
"Description"
119121
type Simple {
120122
attribute: ${graphQLType}
121123
}
124+
"Description"
122125
input Simple${INPUT_SUFFIX} {
123126
attribute: ${graphQLType}
124127
}

0 commit comments

Comments
 (0)