-
Notifications
You must be signed in to change notification settings - Fork 354
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
24 changed files
with
271 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 25 additions & 0 deletions
25
...m/expediagroup/graphql/plugin/client/generator/exceptions/InvalidFragmentFileException.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
/* | ||
* Copyright 2021 Expedia, Inc | ||
* | ||
* Licensed 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 | ||
* | ||
* https://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. | ||
*/ | ||
|
||
package com.expediagroup.graphql.plugin.client.generator.exceptions | ||
|
||
import java.io.File | ||
|
||
/** | ||
* Exception thrown when attempting to generate a client with a fragments file containing not allowed definitions. | ||
*/ | ||
internal class InvalidFragmentFileException(queryFile: File) : | ||
RuntimeException("GraphQL client does not support a fragments file with other definitions than fragments, ${queryFile.name}") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 11 additions & 0 deletions
11
plugins/client/graphql-kotlin-client-generator/src/test/data/fragments/Fragments.graphql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
fragment complexObjectFields on ComplexObject { | ||
id | ||
name | ||
details { | ||
...detailObjectFields | ||
} | ||
} | ||
|
||
fragment detailObjectFields on DetailsObject { | ||
value | ||
} |
5 changes: 5 additions & 0 deletions
5
...rator/src/test/data/fragments/object_named_fragments/ObjectWithNamedFragmentQuery.graphql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
query ObjectWithNamedFragmentQuery { | ||
complexObjectQuery { | ||
...complexObjectFields | ||
} | ||
} |
29 changes: 29 additions & 0 deletions
29
...-generator/src/test/data/fragments/object_named_fragments/ObjectWithNamedFragmentQuery.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package com.expediagroup.graphql.generated | ||
|
||
import com.expediagroup.graphql.client.Generated | ||
import com.expediagroup.graphql.client.types.GraphQLClientRequest | ||
import com.expediagroup.graphql.generated.fragments.ComplexObject | ||
import kotlin.String | ||
import kotlin.reflect.KClass | ||
|
||
public const val OBJECT_WITH_NAMED_FRAGMENT_QUERY: String = | ||
"query ObjectWithNamedFragmentQuery {\n complexObjectQuery {\n ...complexObjectFields\n }\n}\n\nfragment complexObjectFields on ComplexObject {\n id\n name\n details {\n ...detailObjectFields\n }\n}\n\nfragment detailObjectFields on DetailsObject {\n value\n}" | ||
|
||
@Generated | ||
public class ObjectWithNamedFragmentQuery : | ||
GraphQLClientRequest<ObjectWithNamedFragmentQuery.Result> { | ||
override val query: String = OBJECT_WITH_NAMED_FRAGMENT_QUERY | ||
|
||
override val operationName: String = "ObjectWithNamedFragmentQuery" | ||
|
||
override fun responseType(): KClass<ObjectWithNamedFragmentQuery.Result> = | ||
ObjectWithNamedFragmentQuery.Result::class | ||
|
||
@Generated | ||
public data class Result( | ||
/** | ||
* Query returning an object that references another object | ||
*/ | ||
public val complexObjectQuery: ComplexObject, | ||
) | ||
} |
7 changes: 7 additions & 0 deletions
7
...ator/src/test/data/fragments/object_named_fragments/ObjectWithNamedFragmentQuery2.graphql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
query ObjectWithNamedFragmentQuery2 { | ||
complexObjectQuery { | ||
...complexObjectFields | ||
} | ||
} | ||
|
||
|
29 changes: 29 additions & 0 deletions
29
...generator/src/test/data/fragments/object_named_fragments/ObjectWithNamedFragmentQuery2.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package com.expediagroup.graphql.generated | ||
|
||
import com.expediagroup.graphql.client.Generated | ||
import com.expediagroup.graphql.client.types.GraphQLClientRequest | ||
import com.expediagroup.graphql.generated.fragments.ComplexObject | ||
import kotlin.String | ||
import kotlin.reflect.KClass | ||
|
||
public const val OBJECT_WITH_NAMED_FRAGMENT_QUERY2: String = | ||
"query ObjectWithNamedFragmentQuery2 {\n complexObjectQuery {\n ...complexObjectFields\n }\n}\n\nfragment complexObjectFields on ComplexObject {\n id\n name\n details {\n ...detailObjectFields\n }\n}\n\nfragment detailObjectFields on DetailsObject {\n value\n}" | ||
|
||
@Generated | ||
public class ObjectWithNamedFragmentQuery2 : | ||
GraphQLClientRequest<ObjectWithNamedFragmentQuery2.Result> { | ||
override val query: String = OBJECT_WITH_NAMED_FRAGMENT_QUERY2 | ||
|
||
override val operationName: String = "ObjectWithNamedFragmentQuery2" | ||
|
||
override fun responseType(): KClass<ObjectWithNamedFragmentQuery2.Result> = | ||
ObjectWithNamedFragmentQuery2.Result::class | ||
|
||
@Generated | ||
public data class Result( | ||
/** | ||
* Query returning an object that references another object | ||
*/ | ||
public val complexObjectQuery: ComplexObject, | ||
) | ||
} |
26 changes: 26 additions & 0 deletions
26
...lient-generator/src/test/data/fragments/object_named_fragments/fragments/ComplexObject.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package com.expediagroup.graphql.generated.fragments | ||
|
||
import com.expediagroup.graphql.client.Generated | ||
import kotlin.Int | ||
import kotlin.String | ||
|
||
/** | ||
* Multi line description of a complex type. | ||
* This is a second line of the paragraph. | ||
* This is final line of the description. | ||
*/ | ||
@Generated | ||
public data class ComplexObject( | ||
/** | ||
* Some unique identifier | ||
*/ | ||
public val id: Int, | ||
/** | ||
* Some object name | ||
*/ | ||
public val name: String, | ||
/** | ||
* Some additional details | ||
*/ | ||
public val details: DetailsObject, | ||
) |
15 changes: 15 additions & 0 deletions
15
...lient-generator/src/test/data/fragments/object_named_fragments/fragments/DetailsObject.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package com.expediagroup.graphql.generated.fragments | ||
|
||
import com.expediagroup.graphql.client.Generated | ||
import kotlin.String | ||
|
||
/** | ||
* Inner type object description | ||
*/ | ||
@Generated | ||
public data class DetailsObject( | ||
/** | ||
* Actual detail value | ||
*/ | ||
public val `value`: String, | ||
) |
Oops, something went wrong.