Module: BibleQL::QueryBuilder

Defined in:
lib/bibleql/query_builder.rb

Class Method Summary collapse

Class Method Details

.bible_index(translation:) ⇒ Object



218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
# File 'lib/bibleql/query_builder.rb', line 218

def bible_index(translation:)
  {
    query: <<~GQL,
      query($translation: String) {
        bibleIndex(translation: $translation) {
          bookId
          name
          testament
          position
          chapterCount
          chapters {
            number
            verseCount
          }
        }
      }
    GQL
    variables: { translation: translation }
  }
end

.booksObject



46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
# File 'lib/bibleql/query_builder.rb', line 46

def books
  {
    query: <<~GQL,
      query {
        books {
          bookId
          name
          testament
          position
        }
      }
    GQL
    variables: {}
  }
end

.chapter(book, chapter, translation:) ⇒ Object



106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
# File 'lib/bibleql/query_builder.rb', line 106

def chapter(book, chapter, translation:)
  {
    query: <<~GQL,
      query($book: String!, $chapter: Int!, $translation: String) {
        chapter(book: $book, chapter: $chapter, translation: $translation) {
          bookId
          bookName
          chapter
          verse
          text
        }
      }
    GQL
    variables: { book: book, chapter: chapter, translation: translation }
  }
end

.languagesObject



62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
# File 'lib/bibleql/query_builder.rb', line 62

def languages
  {
    query: <<~GQL,
      query {
        languages {
          code
          translationCount
          translations {
            identifier
            name
            language
            note
          }
        }
      }
    GQL
    variables: {}
  }
end

.passage(reference, translation:) ⇒ Object



82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
# File 'lib/bibleql/query_builder.rb', line 82

def passage(reference, translation:)
  {
    query: <<~GQL,
      query($reference: String!, $translation: String) {
        passage(reference: $reference, translation: $translation) {
          reference
          translationId
          translationName
          translationNote
          text
          verses {
            bookId
            bookName
            chapter
            verse
            text
          }
        }
      }
    GQL
    variables: { reference: reference, translation: translation }
  }
end

.random_verse(translation:, testament: nil, books: nil) ⇒ Object



140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
# File 'lib/bibleql/query_builder.rb', line 140

def random_verse(translation:, testament: nil, books: nil)
  {
    query: <<~GQL,
      query($translation: String, $testament: String, $books: String) {
        randomVerse(translation: $translation, testament: $testament, books: $books) {
          bookId
          bookName
          chapter
          verse
          text
        }
      }
    GQL
    variables: { translation: translation, testament: testament, books: books }.compact
  }
end

.search(query_text, translation:, limit: nil) ⇒ Object



157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
# File 'lib/bibleql/query_builder.rb', line 157

def search(query_text, translation:, limit: nil)
  {
    query: <<~GQL,
      query($query: String!, $translation: String, $limit: Int) {
        search(query: $query, translation: $translation, limit: $limit) {
          bookId
          bookName
          chapter
          verse
          text
        }
      }
    GQL
    variables: { query: query_text, translation: translation, limit: limit }.compact
  }
end

.semantic_search(query_text, translation:, limit: nil) ⇒ Object



174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
# File 'lib/bibleql/query_builder.rb', line 174

def semantic_search(query_text, translation:, limit: nil)
  {
    query: <<~GQL,
      query($query: String!, $translation: String, $limit: Int) {
        semanticSearch(query: $query, translation: $translation, limit: $limit) {
          verse {
            bookId
            bookName
            chapter
            verse
            text
          }
          similarity
        }
      }
    GQL
    variables: { query: query_text, translation: translation, limit: limit }.compact
  }
end

.translation(identifier) ⇒ Object



23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/bibleql/query_builder.rb', line 23

def translation(identifier)
  {
    query: <<~GQL,
      query($identifier: String!) {
        translation(identifier: $identifier) {
          identifier
          name
          language
          note
          books {
            bookId
            name
            testament
            position
            chapterCount
          }
        }
      }
    GQL
    variables: { identifier: identifier }
  }
end

.translationsObject



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/bibleql/query_builder.rb', line 7

def translations
  {
    query: <<~GQL,
      query {
        translations {
          identifier
          name
          language
          note
        }
      }
    GQL
    variables: {}
  }
end

.verse(book, chapter, verse, translation:) ⇒ Object



123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
# File 'lib/bibleql/query_builder.rb', line 123

def verse(book, chapter, verse, translation:)
  {
    query: <<~GQL,
      query($book: String!, $chapter: Int!, $verse: Int!, $translation: String) {
        verse(book: $book, chapter: $chapter, verse: $verse, translation: $translation) {
          bookId
          bookName
          chapter
          verse
          text
        }
      }
    GQL
    variables: { book: book, chapter: chapter, verse: verse, translation: translation }
  }
end

.verse_of_the_day(translation:, date: nil) ⇒ Object



194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
# File 'lib/bibleql/query_builder.rb', line 194

def verse_of_the_day(translation:, date: nil)
  {
    query: <<~GQL,
      query($translation: String, $date: ISO8601Date) {
        verseOfTheDay(translation: $translation, date: $date) {
          reference
          translationId
          translationName
          translationNote
          text
          verses {
            bookId
            bookName
            chapter
            verse
            text
          }
        }
      }
    GQL
    variables: { translation: translation, date: date }.compact
  }
end