Skip to content
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

extend type Foo where Foo is actually an interface silently fails when it could give a better error #2206

Open
danzho opened this issue Oct 5, 2024 · 0 comments

Comments

@danzho
Copy link

danzho commented Oct 5, 2024

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.)

@github-project-automation github-project-automation bot moved this to 🌳 Triage in V5.0.0 Oct 5, 2024
@benjie benjie moved this from 🌳 Triage to 🐭 Shrew in V5.0.0 Oct 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: 🐭 Shrew
Development

No branches or pull requests

2 participants
@danzho and others