Skip to content

Commit 0658380

Browse files
gscheibelsmyrick
authored andcommitted
Add example of subquery (#171)
1 parent 248869d commit 0658380

File tree

1 file changed

+31
-0
lines changed
  • example/src/main/kotlin/com/expedia/graphql/sample/query

1 file changed

+31
-0
lines changed
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
package com.expedia.graphql.sample.query
2+
3+
import com.expedia.graphql.annotations.GraphQLDescription
4+
import com.expedia.graphql.annotations.GraphQLIgnore
5+
import org.springframework.beans.factory.BeanFactory
6+
import org.springframework.beans.factory.BeanFactoryAware
7+
import org.springframework.beans.factory.getBean
8+
import org.springframework.context.annotation.Scope
9+
import org.springframework.stereotype.Component
10+
11+
@Component
12+
class SubQueries: Query, BeanFactoryAware {
13+
private lateinit var beanFactory: BeanFactory
14+
15+
@GraphQLIgnore
16+
override fun setBeanFactory(beanFactory: BeanFactory) {
17+
this.beanFactory = beanFactory
18+
}
19+
20+
@GraphQLDescription(
21+
"""Creates a hierarchy of executable fields.
22+
Arguments can be passed from `main` to the `SubQuery` via the constructor invoke by the bean factory"""
23+
)
24+
fun main(): SubQuery = beanFactory.getBean()
25+
}
26+
27+
@Component
28+
@Scope("prototype")
29+
class SubQuery {
30+
fun secondary() = "secondary"
31+
}

0 commit comments

Comments
 (0)