Closed
Description
In version 16.x we are no longer getting the description returned as expected. I've put together a small test case.
This works fine with 15.x
import assert from 'assert';
import {
parse, TypeInfo, validate, visit, visitWithTypeInfo
} from 'graphql';
import { makeExecutableSchema } from '@graphql-tools/schema';
// schemas as defined by server
const schema = makeExecutableSchema({
typeDefs: [
'type Notification {',
' # some description',
' id: ID',
'}',
'type Query { Notification: Notification }'
].join('\n'),
parseOptions: {
commentDescriptions: true
}
});
// ast as defined by query
const ast = parse('query Notification { Notification { id } }');
// making sure everything is fine
const errors = validate(schema, ast);
assert(errors.length === 0);
// the actually changed behavior below
const typeInfo = new TypeInfo(schema);
visit(ast, visitWithTypeInfo(typeInfo, {
enter(node, key, parent, path, ancestors) {
const fieldDef = typeInfo.getFieldDef();
if (fieldDef?.name === 'id') {
console.log([key, fieldDef?.description]);
}
}
}));
// => [ 0, 'some description' ]
// => [ 'name', 'some description' ]
but with 16.x we are getting back
// => [ 0, undefined ]
// => [ 'name', undefined ]
Metadata
Metadata
Assignees
Labels
No labels