Skip to content

Use graphql codegen? #3831

@effigies

Description

@effigies

What would you like to see added?

At least part of #3830 might have been caught if we used graphql-codegen, as the names of the passed variables should be statically checkable.

For using id versus orcid, it looks like there's a way to do tagged types in TypeScript:

declare const tags: unique symbol;

type Tagged<BaseType, Tag extends PropertyKey> = 
  BaseType & { [tags]: { [K in Tag]: void } };

type UserID = Tagged<string, 'User'>
type ORCID = Tagged<string, 'ORCID'>

This is really two separate tasks, and both have potentially far-reaching tendrils, but once done I think we'll end up with something safer.

Alternatives

Instead of codegen, we could start using TypedDocumentNode manually. This would be lower-impact and could be done gradually, but I think it's only worth it if we don't plan to do code generation, as there will still be multiple sources of truth to collate.

Do you have any interest in helping implement the feature?

Yes

Additional information / screenshots

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions