graphile / crystal-pre-merge

Repository moved
https://github.com/graphile/crystal
39 stars 10 forks source link

Polymorphic types aren't added to schema in all cases #490

Open benjie opened 10 months ago

benjie commented 10 months ago

If default behaviors are set such that the concrete type of a polymorphic type (e.g. via @interface mode:union) isn't added to the schema automatically then that type won't appear in the schema even when the interface it implements is being used via e.g. makeExtendSchemaPlugin. This isn't unexpected (you need to add it to types) but we could do this for the use automatically. Maybe.

const AddTypesToSchemaPlugin: GraphileConfig.Plugin = {
  name: "AddTypesToSchemaPlugin",
  version: "0.0.0",
  schema: {
    hooks: {
      GraphQLSchema_types(types, build, context) {
        types.push(build.getTypeByName('VoxMedia'));
        return types;
      }
    }
  }
};

See Discord chat: https://discord.com/channels/489127045289476126/1144207985124577370/1144245182234103819