Skip to content

Instantly share code, notes, and snippets.

@aronbalog
aronbalog / ScrollViewWrapper.swift
Created March 17, 2020 10:57
UIScrollView Wrapper for SwiftUI
import SwiftUI
public struct ScrollViewWrapper<Content: View>: UIViewRepresentable {
@Binding var contentOffset: CGPoint
let content: () -> Content
public init(contentOffset: Binding<CGPoint>, @ViewBuilder _ content: @escaping () -> Content) {
self._contentOffset = contentOffset
self.content = content
}
package com.example.demo.graphql.input
data class PersonInput(
val name: String
)
package com.example.demo.graphql
import com.coxautodev.graphql.tools.GraphQLMutationResolver
import com.example.demo.dao.PersonDao
import com.example.demo.data.Person
import com.example.demo.graphql.input.PersonInput
import org.springframework.stereotype.Component
@Component
class Mutation(
package com.example.demo.dao
import com.example.demo.repository.PersonRepository
import org.springframework.stereotype.Component
@Component
class PersonDao(
private val personRepository: PersonRepository
) {
fun getPersonById(id: String) =
package com.example.demo.graphql
import com.coxautodev.graphql.tools.GraphQLQueryResolver
import org.springframework.stereotype.Component
@Component
class Query: GraphQLQueryResolver {
fun version() = "1.0.0"
}
type Query {
# The API Version
version: String!
# Get person with ID
person(id: ID!): Person
# Get persons by name
personsByName(name: String!): [Person]
}
package com.example.demo.graphql.query
import com.coxautodev.graphql.tools.GraphQLQueryResolver
import com.example.demo.dao.PersonDao
import com.example.demo.data.Person
import org.springframework.stereotype.Component
@Component
class PersonQueryResolver(
private val personDao: PersonDao
package com.example.demo.dao
import com.example.demo.repository.PersonRepository
import org.springframework.stereotype.Component
@Component
class PersonDao(
private val personRepository: PersonRepository
) {
fun getPersonById(id: String) =