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.

Extending an Object Type in Code

See original GitHub issue

(Posting here since haven’t been able to get an answer from any other of channels. 😅)

So, using SDL you can add fields to an existing type like:

extend type Query {
   extraField: Int!
}

But how can I do this in code using the built-in classes (GraphQLObjectType, etc)?

Sounds like extendSchema might offer a way, but it is undocumented and I’m not sure how to use it in this case.

Is this supported?

My apologies in advance if I’m missing something really obvious.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:4
  • Comments:8 (1 by maintainers)

github_iconTop GitHub Comments

2reactions
sibeliuscommented, Jun 29, 2020

can we reopen this?

as extendSchema only works with SDL and not with graphql-js types?

1reaction
tot-racommented, Sep 15, 2020

+1, wanna reference external type for apollo federation as a plain string, but don’t see other way than low-level string replace atm

Read more comments on GitHub >

github_iconTop Results From Across the Web

Extending object-like types with interfaces in TypeScript
There are a few different ways to extend object-like types with interfaces in TypeScript, and, sometimes, you may use type aliases. In those ......
Read more >
How to Extend an Object in JavaScript ? - GeeksforGeeks
The extends keyword can be used to extend the objects as well as classes in JavaScript. It is usually used to create a...
Read more >
extends - JavaScript - MDN Web Docs - Mozilla
The extends keyword can be used to subclass custom classes as well as built-in objects. Any constructor that can be called with new...
Read more >
Extending an Object in Javascript - function - Stack Overflow
You want to 'inherit' from Person's prototype object: var Person = function (name) { this.name = name; this.type = 'human'; }; ...
Read more >
Extending Classes | Think Java | Trinket
In Java, classes may extend only one superclass. Classes that do not specify a superclass with extends automatically inherit from java.lang.Object . So...
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