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

@populatedBy does not work in conjunction with DateTime data type: callback function is not called #4886

Closed
andreloeffelmann opened this issue Mar 15, 2024 · 5 comments · Fixed by #5136
Labels
feature request New feature or request

Comments

@andreloeffelmann
Copy link

Describe the bug
The @populatedBy directive does not work if the field the directive is declared for has the DateTime datatype. The callback function never gets called.

Type definitions

type Request {
  status: Status!
  approvedAt: DateTime @populatedBy(callback: "setApprovedAtTimestampCallback", operations: [UPDATE])
}

enum Status {
  REQUESTED,
  APPROVED
}

To Reproduce
Steps to reproduce the behavior:

  1. Declare the callback function:
const setApprovedAtTimestampCallback: async (root, _parent, _args, context) => {
        return root.status === 'APPROVED' ? new Date().toISOString() : null;
},
  1. Execute the following Mutation...
mutation {
updateRequests(update: { status: APPROVED }){ info { nodesCreated } }
}
  1. See error: the callback function is never called

Expected behavior
The callback function should be called and invoked as described in the docs.

System:

  • Version: @neo4j/graphql@5.2.0
@andreloeffelmann andreloeffelmann added the bug report Something isn't working label Mar 15, 2024
@neo4j-team-graphql neo4j-team-graphql added this to Bug reports in Bug Triage Mar 15, 2024
@neo4j-team-graphql
Copy link
Collaborator

Many thanks for raising this bug report @andreloeffelmann. 🐛 We will now attempt to reproduce the bug based on the steps you have provided.

Please ensure that you've provided the necessary information for a minimal reproduction, including but not limited to:

  • Type definitions
  • Resolvers
  • Query and/or Mutation (or multiple) needed to reproduce

If you have a support agreement with Neo4j, please link this GitHub issue to a new or existing Zendesk ticket.

Thanks again! 🙏

@MacondoExpress MacondoExpress added feature request New feature or request and removed bug report Something isn't working labels Mar 15, 2024
@MacondoExpress
Copy link
Contributor

MacondoExpress commented Mar 15, 2024

Hi @andreloeffelmann ,
You're right DateTime is not supported by the populatedBy, populatedBy is supported only on primitive fields.
We'll update the documentation to reflect this as it's currently not clear that the @populatedBy directive can be used only on primitive fields.
I'll put the label feature request so that we can discuss and prioritize the development.

@andreloeffelmann
Copy link
Author

Hi @MacondoExpress , thanks for the clarification.
I can understand that populatedBy is intended for primitive fields only. However, from the API's consumer point of view, a DateTime is just a String when passing it via GraphQL input fields.
It would be nice if this was supported :-)

@MacondoExpress
Copy link
Contributor

I see and I agree it should not be hard to actually support @populatedBy for complex types, we will have to coerce the callback returned value or instruct the users to return the driver wrapper in case of temporal types and spatial types.

@andreloeffelmann
Copy link
Author

Thanks guys for solving this 👍🏻

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature request New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants