Skip to content
This repository has been archived by the owner on Sep 3, 2021. It is now read-only.

POC fixing extend #279

Closed
wants to merge 3 commits into from
Closed

POC fixing extend #279

wants to merge 3 commits into from

Conversation

wheresrhys
Copy link

Before I start working on fixing tests I thought I'd share this for comment.

The underlying issue is that the library uses a name keyed map of type definitions when beginning its augmentation step. As a type and extensions to it share the same name, the extension definition overwrites the type, and when the schema is finally parsed when being converted into an executable schema the type definition is missing.

The ideal fix would be to refactor the library to not iterate through a data structure keyed by name. The fix in this PR takes the step of merging fields, directives and interfaces defined in extensions with the original list from the definition. I'm guessing this is functionally equivalent to having the extension (extend is more of an authoring utility as far as I can see, rather than offering api capabilities above and beyond using a type definition alone), though am happy to be corrected. Even if it is functionally equivalent, this manipulation of the types does feel a bit dirty.

Let me know what you think @johnymontana

Addresses #208

@johnymontana
Copy link
Contributor

Thanks @wheresrhys - @michaeldgraham is currently working on a refactor of the augmentation process that I think should address this.

@michaeldgraham can chime in here but I think we're aiming to have it in the next week or so.

@michaeldgraham
Copy link
Collaborator

michaeldgraham commented Jul 18, 2019

Hey @wheresrhys, thanks for bringing this up! I have been working on a nearly total re-write of the augmentation process (shouldn't be much longer). It will remove a few bugs and should make moving forward with some features a less complex, cleaner task.

A few weeks ago I took a turn in the design in order to ensure this issue with extend doesn't persist. It grew out of my original, silly attempts to prevent generating duplicate types and/or overwriting authored types. This re-write makes use of the GraphQL visit utility function and I've put together more minimal, less hacky AST building helpers. It's been much more consistent and flexible for me, so I'm really looking forward to getting it wrapped up for everyone! :)

So how about after it's wrapped up, we work together on some tests that show all sorts of type extensions being used or not used in various ways? It should be cool to experiment with Apollo Federation (which uses extend) too!

@wheresrhys
Copy link
Author

Great that you're addressing this. I can't guarantee to be available to collaborate much on tests (investigating why extend wasn't working was a little 10% time project), but happy to be added as a reviewer.

@wheresrhys wheresrhys closed this Jul 18, 2019
@wheresrhys
Copy link
Author

Hi @michaeldgraham - has there been any progress on this?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants