edgedb / edgedb-js

The official TypeScript/JS client library and query builder for EdgeDB
https://edgedb.com
Apache License 2.0
514 stars 65 forks source link

Polymorphic field is not present #1109

Closed Gobot1234 closed 1 month ago

Gobot1234 commented 1 month ago

Code The code causing the error.

https://github.com/iforge-uos/ignis/blob/feature/protein-filled-dinner/apps/anvil/src/training/training.service.ts#L39

  async getTraining(id: string, editing?: boolean): Promise<training.Training> {
    const x = e
      .assert_exists(
        e.select(e.training.Training, () => ({
          ...(editing
            ? {
                ...e.training.Training["*"],
                sections: TrainingSection,
              }
            : {...}),
          enabled: true,
          rep: { id: true, name: true, description: true },
          filter_single: { id },
        })),
      );
    console.log(x.toEdgeQL());
  }

refs: https://discord.com/channels/841451783728529451/1265373494561083583

Schema

https://github.com/iforge-uos/ignis/tree/feature/protein-filled-dinner/apps/anvil/dbschema/training.esdl

Generated EdgeQL

None, error generated

Error or desired behavior

anvil:dev:     'Error: Field "index" does not exist in training::Question | training::TrainingPage\n' +
anvil:dev:       '    at shapeToEdgeQL (/Users/James/Programming/ignis/apps/anvil/dbschema/edgeql-js/toEdgeQL.ts:1338:15)\n' +
anvil:dev:       '    at renderEdgeQL (/Users/James/Programming/ignis/apps/anvil/dbschema/edgeql-js/toEdgeQL.ts:968:11)\n' +
anvil:dev:       '    at shapeToEdgeQL (/Users/James/Programming/ignis/apps/anvil/dbschema/edgeql-js/toEdgeQL.ts:1375:26)\n' +
anvil:dev:       '    at Array.map (<anonymous>)\n' +
anvil:dev:       '    at renderEdgeQL (/Users/James/Programming/ignis/apps/anvil/dbschema/edgeql-js/toEdgeQL.ts:1148:32)\n' +
anvil:dev:       '    at Proxy.$toEdgeQL (/Users/James/Programming/ignis/apps/anvil/dbschema/edgeql-js/toEdgeQL.ts:319:16)\n' +
anvil:dev:       '    at TrainingService.getTraining (/Users/James/Programming/ignis/apps/anvil/src/training/training.service.ts:56:8)\n' +
anvil:dev:       '    at TrainingController.getTraining (/Users/James/Programming/ignis/apps/anvil/src/training/training.controller.ts:41:33)'
anvil:dev:   ]

Versions (please complete the following information):