crystal
crystal copied to clipboard
`extend type Foo` where Foo is actually an interface silently fails when it could give a better error
Discord context: https://discord.com/channels/489127045289476126/498852330754801666/1292111166235082803
This is the code I tried to write:
// comment on table app.users is $$
// @interface mode:relational type:kind
// @type MEMBER references:members
// @type ADMIN references:admins
// $$;
export const TestPlugin = makeExtendSchemaPlugin(() => {
return {
typeDefs: gql`
extend type User {
foo1: String
}
extend type Member {
foo2: String
}
extend type Admin {
foo3: String
}
`,
plans: {
User: {
// foo1 not in the schema.sql
foo1() {
return constant("bar");
},
},
Member: {
foo2() { // works
return constant("bar");
},
},
Admin: {
foo3() { // works
return constant("bar");
},
},
},
};
});
That’s coz you’re using extend type which applies to object types; you want extend interface since it’s an interface.
Please file an issue about this; we can be more helpful and throw an error on type mismatch. (Currently the type is never seen so the extension never triggers.)