Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Regression v16: typeInfo.getFieldDef() missing description 馃悰 #3606

Closed
simlu opened this issue May 27, 2022 · 1 comment
Closed

Regression v16: typeInfo.getFieldDef() missing description 馃悰 #3606

simlu opened this issue May 27, 2022 · 1 comment

Comments

@simlu
Copy link

simlu commented May 27, 2022

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 ]
@simlu
Copy link
Author

simlu commented May 27, 2022

It looks like comment descriptions were deprecated and are now completely removed as per #2900

@simlu simlu closed this as completed May 27, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant