I see some commits that adds the following syntax
type Hello {
world: String
}
extend type Hello {
world2: String
}
However I can't find any docs around just what it is and how to use it. And if I actually try to use it in code I get the following message.
Error: Client Schema cannot be used for execution.
Can someone clarify how to use type extension in GraphQL?
Hey @tonyxiao, can you please post the code you're running to execute type extension?
Hmm I was using it together with ApolloStack. apollostack.com Maybe they are using an older version of graphql js and that's why there's error?
Sounds like it should be an issue on graphql-tools? https://github.com/apollostack/graphql-tools
I'd close the one here.
Closing this since I haven't seen any movement on this for a while. @tonyxiao, please feel free to re-open if feel there's something specific and actionable we can do in this repo.
feel free to open an issue on graphql tools about documenting this.
I'm still seeing extend not work at all with graphql or express-graphql. Minimal failing example attached.
import { buildSchema, graphql } from 'graphql';
const schema = buildSchema(`
type QuerySubset {
hello: String
}
type Queries {
querySubset: QuerySubset
}
extend type Queries {
hello: String
}
type Query {
Queries: Queries
}
schema {
query: Query
}
`)
const rootResolver = {
Queries: {
querySubset: {
hello: () => 'hello world',
},
hello: () => 'hello world',
}
};
// Works fine
graphql(schema, `{ Queries { querySubset { hello } } }`, rootResolver).then(response => {
console.log(response);
})
// Errors out with 'Cannot query field "hello" on type "Queries".'
graphql(schema, `{ Queries { hello } }`, rootResolver).then(response => {
console.log(response);
})
Why is this closed? I would like to know how the extend keyword works and it's not documented.
@krabbypattified See the closed issue #892 and associated issue #922
TL;DR - use graphql-tools for now.
Most helpful comment
Why is this closed? I would like to know how the
extendkeyword works and it's not documented.