Intended way to return a union like `union Result = User | UsernameTaken | ...` in v5?
Note: This is a question for grafast / postgraphile v5.

There are no google results for the error message I'm getting (shared later on), so hopefully this issue could at least answer some questions.

### Summary

I want a graphql function to return a union of a table row and other data objects. Though this question is general, my concrete use-case is that I want my `registerUser()` function to return `User | UnameTaken | EmailTaken`. 

I should also note that I have a `app_public.user` table and postgraphile has already created a `User` type for it that my code already works with. I'm just trying to add some local `UnameTaken` and `EmailTaken` types here for the registration result.

(Traditionally, you would represent these as error codes for the client to check `err.code == "UNAME_TAKEN"`. However, these data objects let us pass along additional, arbitrary information to the client.)

So my graphql declaration looks like this.

```graphql
input RegisterUserInput {
    uname: String!
    email: String!
}

type UnameTaken {
    message: String!
}

type EmailTaken {
    message: String!
}

union RegisterUserResult = User | UnameTaken | EmailTaken

type RegisterUserPayload {
    result: RegisterUserResult
    query: Query
}

extend type Mutation {
    registerUser(input: RegisterUserInput!): RegisterUserPayload
}
```

When I try to execute `registerUser()`, I get this error:

```
Error occurred during query planning:
Error: The 'RegisterUserResult' interface or union type's first type 'User' expected a plan, however the type 'UnameTaken' (index = 1) did not expect a plan. All types in an interface or union must be in agreement about whether a plan is expected or not.
```

I've tried various things like register UnameTaken under the plugin's `plans` property, but I haven't had any luck making progress here.

----

Here is the full RegisterUserPlugin that sets all of this up:

```typescript
import { makeExtendSchemaPlugin, gql } from 'postgraphile/utils'
import { access, constant, object } from 'postgraphile/grafast'
import { withPgClientTransaction } from 'postgraphile/@dataplan/pg'

const RegisterUserPlugin = makeExtendSchemaPlugin((build) => {
    const { user } = build.input.pgRegistry.pgResources
    const { executor } = user
    return {
        typeDefs: gql`
            input RegisterUserInput {
                uname: String!
                email: String!
            }

            type UnameTaken {
                message: String
            }

            type EmailTaken {
                message: String
            }

            union RegisterUserResult = User | UnameTaken | EmailTaken

            type RegisterUserPayload {
                result: RegisterUserResult
                query: Query
            }

            extend type Mutation {
                registerUser(input: RegisterUserInput!): RegisterUserPayload
            }
        `,
        plans: {
            Mutation: {
                registerUser2(_, fieldArgs) {
                    const $input = fieldArgs.getRaw('input')

                    const $result = withPgClientTransaction(
                        executor,
                        $input,
                        async (pgClient, input) => {
                            let user
                            try {
                                const { rows } = await pgClient.query({
                                    text: `
                                        INSERT INTO app_public.user (uname)
                                        VALUES ($1)
                                        RETURNING *`,
                                    values: [input.uname],
                                })
                                user = rows[0]
                            } catch (e) {
                                // Check if uname taken
                                if (
                                    (e as any).code === '23505' &&
                                    (e as any).constraint ===
                                        'unique_user_uname'
                                ) {
                                    return {
                                        __typename: 'UnameTaken',
                                        message: '...',
                                    }
                                } // check if email taken
                                else if (
                                    (e as any).code === '23505' &&
                                    (e as any).constraint ===
                                        'unique_user_email'
                                ) {
                                    return {
                                        __typename: 'EmailTaken',
                                        message: '...',
                                    }

                                }
                                throw e
                            }

                            await pgClient.query({
                                text: `
                                    INSERT INTO app_secret.user_emails(user_id, email)
                                    VALUES ($1, $2)
                                `,
                                values: [user.id, input.email],
                            })

                            await sendEmail(input.email, 'Welcome!')

                            return user
                        },
                    )

                    return object({ result: $result })
                },
            },

            RegisterUserPayload: {
                result($data) {
                    return $data.get('result')
                },
                query($data) {
                    return constant(true)
                },
            },
        },
    }
})

```

I know it's not fully correct. It doesn't rollback the transaction (I don't even think you can do that inside the withTransaction helper). But it's a minimal code example to give us something concrete to work with.

Thanks for any help.

