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.

Replicate descriptions from interfaces to the types that implement the interface

See original GitHub issue

Describe the problem

Currently, magidoc beautifully displays the descriptions that are present in our GraphQL schema. Our schema makes extensive use of GraphQL interfaces. That is, we’ll define an interface in a common place, and then define concrete types in one or more other model files. As you know, when a type implements an interface, all the field names in the interface must be specified in the type. Because of this, if we add descriptions to the fields in an interface, it would be nice if those descriptions would propagate to the concrete types that implement the interface, presuming the concrete type hasn’t already added a description for the field. This way, we only have to provide a description once, and it will automatically get replicated to the places it applies.

Describe the proposed solution

Either makes this built-in behavior, or provide an option in the mjs config file to control if descriptions are propagated from interfaces to other interfaces or types that implement the interface, if that implementing interface/type doesn’t provide its own.

interface MyInterface {
   """ Interface-provided description of field1 """
   field1: String!

   """ Interface-provided description of field2 """
   field2: String!
}

interface MyType implements MyInterface {
   field1: String!

   """ Type-provided description of field2 """
   field2: String!
}

Given the above schema, when magidoc processes the schema, it would recognize that MyType:field1 does not have a description, so it propagates the description from MyInterface:field1 to MyType:field1. Also, magidoc would recognize that MyType:field2 has provided a description, so magidoc would not copy the description from the MyInterface:field2.

Alternatives considered

It’s possible this functionality could be implemented in a graphql codegen plugin (such as in the schema-ast or introspection plugin). But, if someone isn’t using a codegen plugin, but rather doing a live introspection query, they could not benefit from this behavior.

Importance

would make my life easier

Additional Information

There are many benefits to this functionality. First, for users of the static doc, they will see descriptions all the way from interfaces to the concrete types. For us developers, we only have to write our descriptions once, and get all the benefits of not copy/pasting descriptions from interfaces from concrete implementations.

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:6

github_iconTop GitHub Comments

1reaction
BoilerTom90commented, Aug 10, 2022

I did a quick sanity test of this improvement, and it looks like it’s working. Thanks again for the quick turnaround!

1reaction
BoilerTom90commented, Aug 10, 2022

Thank you for the quick turnaround! I’ll try this first thing tomorrow morning

~~~~~~~~~~~~~~~~~~~ Tom Hoffman

On Tue, Aug 9, 2022 at 7:59 PM Sunny Pelletier @.***> wrote:

There is currently an outage with Github, I will merge and deploy it as soon as possible.

— Reply to this email directly, view it on GitHub https://github.com/magidoc-org/magidoc/issues/143#issuecomment-1210034392, or unsubscribe https://github.com/notifications/unsubscribe-auth/AEDJHP2BNQK4AU4FGADUVGLVYL5GDANCNFSM56B67GOA . You are receiving this because you authored the thread.Message ID: @.***>

Read more comments on GitHub >

github_iconTop Results From Across the Web

Handbook - Interfaces - TypeScript
Interfaces are capable of describing the wide range of shapes that JavaScript objects can take. In addition to describing an object with properties,...
Read more >
Sharing types and fields: interfaces | Federation 2 Lab
I've updated the Attraction interface in the activities subgraph with a new field, ... type Activity implements Attraction @key(fields: "id") {.
Read more >
A Simple Guide to Typescript Interfaces: declaration & use cases
An interface is an abstract type that tells the compiler which property names a given object can have. Learn how to create and...
Read more >
Interfaces - Visual Basic | Microsoft Learn
Interfaces define the properties, methods, and events that classes can implement. Interfaces allow you to define features as small groups of ...
Read more >
Java Interfaces | Baeldung
In Java, an interface is an abstract type that contains a collection of methods and constant variables. It is one of the core...
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