Skip to content

Commit 5682950

Browse files
Alan-ChaErikWittern
authored andcommitted
Fix descriptions and add test
Signed-off-by: Alan Cha <[email protected]>
1 parent 1c0f96a commit 5682950

File tree

4 files changed

+39
-5
lines changed

4 files changed

+39
-5
lines changed

packages/openapi-to-graphql/lib/schema_builder.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/openapi-to-graphql/lib/schema_builder.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/openapi-to-graphql/src/schema_builder.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -441,9 +441,9 @@ function createFields({
441441
: (objectType as GraphQLOutputType),
442442

443443
description:
444-
typeof def.schema.description === 'undefined'
444+
typeof schema.description === 'undefined'
445445
? 'No description available.'
446-
: def.schema.description
446+
: schema.description
447447
}
448448
}
449449
}

packages/openapi-to-graphql/test/example_api.test.js

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,40 @@ afterAll(() => {
4141
return stopServer()
4242
})
4343

44+
test('Get descriptions', () => {
45+
let query = `{
46+
__type(name: "Car") {
47+
name
48+
fields {
49+
description
50+
}
51+
}
52+
}`
53+
return graphql(createdSchema, query).then(result => {
54+
expect(result).toEqual({
55+
data: {
56+
__type: {
57+
name: 'Car',
58+
fields: [
59+
{
60+
description: 'The color of the car.'
61+
},
62+
{
63+
description: 'No description available.'
64+
},
65+
{
66+
description: 'The model of the car.'
67+
},
68+
{
69+
description: 'Arbitrary (string) tags describing an entity.'
70+
}
71+
]
72+
}
73+
}
74+
})
75+
})
76+
})
77+
4478
test('Get resource (incl. enum)', () => {
4579
let query = `{
4680
user (username: "arlene") {

0 commit comments

Comments
 (0)