question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Preserve order when generating TypeScript definitions

See original GitHub issue

Currently each time the CLI is executed, the TypeScript definitions come out the same, which is correct, but the order of the definitions is not kept constant.

I’d like to propose some type of ordering which keeps the generated file the same, unless some of the definitions actually changed.

Config used when testing this:

schema: "http://localhost:8080/graphql"
documents: "src/**/*.{ts,tsx}"
generates:
  src/gql-types.ts:
    plugins:
      - "typescript"
      - "typescript-operations"
config:
 skipTypename: true
 declarationKind: 'interface'```

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:6
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
Zachecommented, May 8, 2021

Prettier won’t change the order of type declarations or properties. It’s pretty annoying that things like the Scalars can change order when generating types from an updated schema that didn’t change anything close to them.

I would kind of expect the types to always be generated in the order they are specified in the schema.

0reactions
dotansimhacommented, Jun 20, 2021

Could you try with the alpha versions here;

https://github.com/dotansimha/graphql-code-generator/pull/5982#issuecomment-838547015

Closing. If someone is still experiencing it, please refer to @ardatan 's reply

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to preserve variadic type order for conditionally inferred ...
I have the following type definition:
Read more >
Documentation - Publishing - TypeScript
If your types are generated by your source code, publish the types with your source code. Both TypeScript and JavaScript projects can generate...
Read more >
Documentation - tsc CLI Options - TypeScript
Flag Type Default ‑‑allowJs boolean false ‑‑allowUmdGlobalAccess boolean false ‑‑allowUnreachableCode boolean
Read more >
TSConfig Reference - Docs on every TSConfig option
Output Formatting. noErrorTruncation,; preserveWatchOutput and; pretty ... Generate .d.ts files for every TypeScript or JavaScript file inside your project.
Read more >
Documentation - Type Declarations - TypeScript
The answer is that there are declaration files describing these built-in objects. A declaration file provides a way to declare the existence of...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found