Closed frasern closed 1 month ago
Please raise a PR to make the change you suggest :+1:
The V4 preset implements this smart tag, but the V5 preset does not; this was because I decided that consistently calling the results "result" would make more sense than having "boolean" and "float" all over the place. But if you want to explicitly change the name you should still be able to, and the smart tag is a strong signal of this, so I support the change you recommend :+1:
Summary
The
@resultFieldName
Smart Tag no longer seems to work in V5. It is still in the docs and I couldn't find any mention of it being deprecated or replaced, so this appears to be a regression.Steps to reproduce
Define a function in Postgres and set the
@resultFieldName
smart tag:Run the mutation in GraphQL:
Expected results
✅ V4 gives the expected result, with the result field being correctly named foo:
Actual results
❌ V5.0.0-beta.16 (running Postgraphile with only the amber preset
npx postgraphile -P postgraphile/presets/amber -c postgres://...
) gives an error for the same query:Additional context
It appears that default field name (result) always gets used instead of the one specified by the Smart Tag, so you can get the value by requesting the result field:
Possible Solution
Changing this function:
https://github.com/graphile/crystal/blob/775af9c6c6c99685890a4d06b8019f00317f3f77/graphile-build/graphile-build-pg/src/plugins/PgCustomTypeFieldPlugin.ts#L328-L330
to
resolves the issue, but I don't know if that is the appropriate fix. It is based on some logic I found in PgV4InflectionPlugin.ts.