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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

diff falsely detects added @deprecation directive #2847

Open
4 tasks
bessey opened this issue Feb 17, 2025 · 1 comment
Open
4 tasks

diff falsely detects added @deprecation directive #2847

bessey opened this issue Feb 17, 2025 · 1 comment
Assignees
Labels
🐞 bug Something isn't working

Comments

@bessey
Copy link

bessey commented Feb 17, 2025

Issue workflow progress

Progress of the issue based on the
Contributor Workflow

  • 1. The issue provides a reproduction available on GitHub, Stackblitz or CodeSandbox

    Make sure to fork this template and run pnpm generate in the terminal.

    Please make sure the Codegen and plugins version under package.json matches yours.

  • 2. A failing test has been provided
  • 3. A local solution has been provided
  • 4. A pull request is pending review

Describe the bug

When comparing two identical schemas featuring a @deprecated field, graphql-inspector diff falsely detects the @deprecated directive as being an addition when it is unchanged.

This seems to be specifically when comparing a typeDef string to an HTTP endpoint.

There is no difference in output between these two commands:
pnpm exec graphql-inspector introspect ./scripts/makeGraphQLSchema.ts --require ts-node/register
pnpm exec graphql-inspector introspect https://my-prod-env/graphql
Confirming I think that this is an actual bug in the diff algo and not environmental

I also cannot reproduce if I diff using HTTP for both old and new. In this case I get no changes detected

To Reproduce Steps to reproduce the behavior:

pnpm exec graphql-inspector diff https://my-prod-env/graphql ./scripts/makeGraphQLSchema.ts --require ts-node/register

Output:

Detected the following changes (1) between schemas:

✔  Directive deprecated was added to field Mutation.raiseAdditionalWorkRequestForEvent
success No breaking changes detected

Expected behavior

No difference in schema.

Environment:

  • OS:
  • @graphql-inspector/cli: 5.0.8
  • graphql: 16.10.0 (and 16.8.1, I tried upgrading)
  • NodeJS: v20.16.0

Additional context

Contents of my script:

// ./scripts/makeGraphQLSchema.ts
import { makeExecutableSchema } from '@graphql-tools/schema';
import {
  HexColorCodeResolver as Colour,
  DateResolver as Date,
  DateTimeResolver as DateTime,
  JSONObjectResolver as JSONObject,
  TimeResolver as Time,
  TimeZoneResolver as TimeZone,
} from 'graphql-scalars';
import typeDefs from './typeDefs';

const resolvers = {
  Date,
  DateTime,
  Time,
  TimeZone,
  Colour,
  JSONObject,
};

export default makeExecutableSchema({ typeDefs, resolvers });

We use GraphQL codegen to combine a bunch of *.graphql definitions into a single typeDef. We version control the generated typeDef though so I can say with confidence that it does contain the @deprecated field.

@TuvalSimha
Copy link
Collaborator

Hey @bessey ,

First of all, thank you very much for bringing up this issue!

I tried to reproduce it, and I got the same results as you described. You can check out the temporary repo I set up for testing: LINK.

I need to investigate further to understand why this is happening. I'll provide an update as soon as I have more insights.

Thanks again for your patience! 🚀

@TuvalSimha TuvalSimha added the 🐞 bug Something isn't working label Feb 24, 2025
@TuvalSimha TuvalSimha self-assigned this Feb 24, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐞 bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants