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 Queries to ModuleDSL #109

Open
johanhaleby opened this issue Oct 24, 2021 · 0 comments
Open

Add Queries to ModuleDSL #109

johanhaleby opened this issue Oct 24, 2021 · 0 comments

Comments

@johanhaleby
Copy link
Owner

johanhaleby commented Oct 24, 2021

val myRepository = ...
val myModule = module {
	...

	queries {
                query("stuff") {
                          myRepository.findStuff()
                 }
		domainEventQuery("AllStartedGames") { domainEventQueries ->
			domainEventQueries.queryForSequence<GameStarted>()
		}
	}

}

then use it in e.g. rest API:

val allStartedGames = myModule.query("AllStartedGames")

We could also create queries with types:

val myModule = module {
	...

	queries {
		domainEventQuery<AllStartedGames> { domainEventQueries ->
			domainEventQueries.queryForSequence<GameStarted>()
		}
	}

}

and then:

val allStartedGames = myModule.query<AllStartedGames>

Maybe the interface (AllStartedGames) could somehow define the return type of the Query? If so we probably need to introduce a Query interface such as Query<T> where T is the return type.

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

No branches or pull requests

1 participant