-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Extending an Object Type in Code #1569
Comments
@ldiego08 Yes, it's supported. Our documentation lagging behind since it had last major updated in 2016. Discussed in #1368 For example on how to use |
@IvanGoncharov Sorry to ask this after a while, but do we have now docs about this? |
can we reopen this? as extendSchema only works with SDL and not with graphql-js types? |
+1, wanna reference external type for apollo federation as a plain string, but don't see other way than low-level string replace atm |
+1, any ideas on how to do this via code |
+1, how to use "extend" with GraphQLObjectType? |
I was just experimenting with this and it turns out you can force the "extend type ..." in the SDL string output, if you do the following: new GraphQLObjectType({
...
name: "*NAME HERE*",
astNode: {kind: "ObjectTypeExtension", name: {kind: "Name", value: "*NAME HERE*"}},
extensionASTNodes: [{kind: "ObjectTypeExtension", name: {kind: "Name", value: "*NAME HERE*"}}],
...
}) You need to set both. This won't interfere with the fields, but you may need to put directives yourself in "astNode" then, not sure. |
Is there anything like this? |
(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:
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.
The text was updated successfully, but these errors were encountered: