# * Licensed to the Apache Software Foundation (ASF) under one
# * or more contributor license agreements.  See the NOTICE file
# * distributed with this work for additional information
# * regarding copyright ownership.  The ASF licenses this file
# * to you under the Apache License, Version 2.0 (the
# * "License"); you may not use this file except in compliance
# * with the License.  You may obtain a copy of the License at
# *
# *   http://www.apache.org/licenses/LICENSE-2.0
# *
# * Unless required by applicable law or agreed to in writing,
# * software distributed under the License is distributed on an
# * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# * KIND, either express or implied.  See the License for the
# * specific language governing permissions and limitations
# * under the License.

"""
GraphQL Schema used for our tests
"""
type Query {
    currentResource : SlingResource @fetcher(name:"echoNS/echo")

    # Test some static values
    staticContent: Test @fetcher(name:"test/static")

    # Test combined as return type
    combinedFetcher: Test2 @fetcher(name:"combined/fetcher")

    # Test union query
    unionQuery: CharactersAsUnion @fetcher(name:"character/fetcher")

    # Test interface query
    interfaceQuery: CharactersAsInterface @fetcher(name:"character/fetcher")

    lazyQuery(boolVar : Boolean, intVar : Int, floatVar: Float) : ExpensiveObject @fetcher(name:"lazy/fetcher")
}

interface CharacterInterface @resolver(name:"character/resolver" source:"CharacterInterface") {
  id: ID!
}

union CharacterUnion @resolver(name:"character/resolver" source:"CharacterUnion") = Human | Droid

type ExpensiveObject {
  expensiveName : String!
  expensiveNameClone : String!
  cheapCount : Int
}

# This should be omitted from the SlingResource type description
#
# SlingResource, for our tests
type SlingResource { 
    path: String
    resourceType: String

    pathMD5: String @fetcher(name:"sling/digest" options:"md5" source:"path")

    # SHA256 digest of the path
    pathSHA256: String @fetcher(name:"sling/digest" options:"sha-256" source:"path")

    # MD5 digest of the resource type
    resourceTypeMD5: String @fetcher(name:"sling/digest" options:"md5" source:"resourceType")

    nullValue: String @fetcher(name:"echoNS/echo" options:"null")

    # Failure message
    failure: String @fetcher(name:"failure/fail")
}

type Test { 
    test: Boolean
    boolValue: Boolean
    resourcePath: String
    testingArgument: String
}

type Test2 {
    boolValue: Boolean
    resourcePath: String
    aTest: Test
    allTests: [Test]
    unionTest: [CharacterUnion]
    interfaceTest: [CharacterInterface]
}

type CharactersAsUnion {
    characters: [CharacterUnion]
}

type CharactersAsInterface {
    characters: [CharacterInterface]
}

type Human implements CharacterInterface {
  id: ID!
  name: String!
  address: String
}

type Droid implements CharacterInterface {
  id: ID!
  name: String!
  primaryFunction: String
}

