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

Add web support for Statement #2952

Open
abccbaandy opened this issue Sep 20, 2024 · 5 comments
Open

Add web support for Statement #2952

abccbaandy opened this issue Sep 20, 2024 · 5 comments
Labels
status: feedback-provided Feedback has been provided

Comments

@abccbaandy
Copy link

abccbaandy commented Sep 20, 2024

Something like this
https://docs.spring.io/spring-data/jpa/reference/repositories/core-extensions.html#core.web.type-safe

Currently it seems not work with Statement.

Caused by: com.fasterxml.jackson.databind.exc.InvalidDefinitionException: Cannot construct instance of `org.neo4j.cypherdsl.core.Statement` (no Creators, like default constructor, exist): abstract types either need to be mapped to concrete types, have custom deserializer, or contain additional type information

Test with spring boot 3.3.3

Please add web support, it's very useful for write a complex query api.

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Sep 20, 2024
@spring-projects spring-projects deleted a comment Sep 23, 2024
@meistermeier
Copy link
Collaborator

Could you have a look here? https://github.com/meistermeier/neo4j-issues-examples/tree/master/gh-2952
This works with a User node and the given properties.
Maybe it is possible to see your controller method and the request query for a better reproducer.

@meistermeier meistermeier added status: waiting-for-feedback We need additional information before we can continue and removed status: waiting-for-triage An issue we've not yet triaged labels Nov 21, 2024
@spring-projects-issues
Copy link

If you would like us to look at this issue, please provide the requested information. If the information is not provided within the next 7 days this issue will be closed.

@spring-projects-issues spring-projects-issues added the status: feedback-reminder We've sent a reminder that we need additional information before we can continue label Nov 28, 2024
@abccbaandy
Copy link
Author

Could you have a look here? https://github.com/meistermeier/neo4j-issues-examples/tree/master/gh-2952
This works with a User node and the given properties.

Do you have cypher DSL version?

Maybe it is possible to see your controller method and the request query for a better reproducer.

My api still work in progress and I want use cypher DSL way seems it is recommended in official reference.
https://docs.spring.io/spring-data/neo4j/reference/repositories/sdn-extension.html#sdn-mixins.dynamic-conditions

Also I found there is an official support cypher parser.
https://neo4j.github.io/cypher-dsl/2024.1.0/#cypher-parser
But it seems need call parse manually instead use in controller directly.

Anyways, I want the api looks like this:
request

/search?dsl=123 in someList and name='some ppl name'

code

    @PostMapping("/search")
    public List<People> search(@RequestParam org.neo4j.cypherdsl.core.Condition dsl) {
          return peopleRepository.findAll(dsl);
    }

public interface PeopleRepository extends Neo4jRepository<Person, Long>,
    CypherdslConditionExecutor<Person>, 
    CypherdslStatementExecutor<Person> { 
}

@spring-projects-issues spring-projects-issues added status: feedback-provided Feedback has been provided and removed status: waiting-for-feedback We need additional information before we can continue status: feedback-reminder We've sent a reminder that we need additional information before we can continue labels Nov 28, 2024
@michael-simons
Copy link
Collaborator

The parser will just return an AST fragment if you parse in a fragment. That fragment than needs to be added to the shell you did build with the cypher DSL
If it is always a condition, that will work as well and you can use the CypherDSLConditionExecutor.

Here's basically what you want to do:

https://github.com/neo4j/cypher-dsl/blob/0f8cde90ec346ee6d3ddfdd7418b46a97511cad3/neo4j-cypher-dsl-examples/neo4j-cypher-dsl-examples-sdn6/src/main/java/org/neo4j/cypherdsl/examples/sdn6/movies/PeopleService.java#L76-L96

Here's an example to use the CypherDSL with hole statements:

https://github.com/neo4j/cypher-dsl/blob/0f8cde90ec346ee6d3ddfdd7418b46a97511cad3/neo4j-cypher-dsl-examples/neo4j-cypher-dsl-examples-sdn6/src/main/java/org/neo4j/cypherdsl/examples/sdn6/movies/MovieService.java#L52-L74

I think that's actually all you need and I would suggest closing this issue. There's nothing we are gonna add in terms of web support, it's all there already.

@abccbaandy
Copy link
Author

I don't get it.
Your link is for parse manually, I want parse in controller level automatically.
Like my comment here.
#2952 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: feedback-provided Feedback has been provided
Projects
None yet
Development

No branches or pull requests

4 participants