-
Notifications
You must be signed in to change notification settings - Fork 41
Add tests for @Source used with other inputs
#218
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
60 changes: 60 additions & 0 deletions
60
.../tck/src/main/java/org/eclipse/microprofile/graphql/tck/apps/basic/api/SourceTestApi.java
This file contains hidden or 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,60 @@ | ||
| /* | ||
| * Copyright (c) 2020 Contributors to the Eclipse Foundation | ||
| * | ||
| * 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 | ||
| * | ||
| * 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. | ||
| */ | ||
| package org.eclipse.microprofile.graphql.tck.apps.basic.api; | ||
|
|
||
| import java.time.LocalDate; | ||
| import java.time.format.DateTimeFormatter; | ||
|
|
||
| import org.eclipse.microprofile.graphql.DateFormat; | ||
| import org.eclipse.microprofile.graphql.DefaultValue; | ||
| import org.eclipse.microprofile.graphql.GraphQLApi; | ||
| import org.eclipse.microprofile.graphql.Name; | ||
| import org.eclipse.microprofile.graphql.NonNull; | ||
| import org.eclipse.microprofile.graphql.Query; | ||
| import org.eclipse.microprofile.graphql.Source; | ||
|
|
||
| /** | ||
| * {@code @Source} testing. | ||
| */ | ||
| @GraphQLApi | ||
| public class SourceTestApi { | ||
|
|
||
| @Query | ||
| public SourceType getSource() { | ||
| return new SourceType(); | ||
| } | ||
|
|
||
| public String stringInput(@Source SourceType source, String input) { | ||
| return "Input was: " + input; | ||
| } | ||
|
|
||
| public String nonNullStringInput(@Source SourceType source, @NonNull String input) { | ||
| return "Input was: " + input; | ||
| } | ||
|
|
||
| public String namedStringInput(@Source SourceType source, @Name("in") String input) { | ||
| return "Input was: " + input; | ||
| } | ||
|
|
||
| public String defaultStringInput(@Source SourceType source, @DefaultValue("Default value") String input) { | ||
| return "Input was: " + input; | ||
| } | ||
|
|
||
| public String dateInput(@Source SourceType source, @DateFormat(value = "yyyy-MM-dd") LocalDate input) { | ||
| return "Input was: " + (input != null ? input.format(DateTimeFormatter.ISO_DATE) : null); | ||
| } | ||
|
|
||
| } | ||
22 changes: 22 additions & 0 deletions
22
server/tck/src/main/java/org/eclipse/microprofile/graphql/tck/apps/basic/api/SourceType.java
This file contains hidden or 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,22 @@ | ||
| /* | ||
| * Copyright (c) 2020 Contributors to the Eclipse Foundation | ||
| * | ||
| * 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 | ||
| * | ||
| * 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. | ||
| */ | ||
| package org.eclipse.microprofile.graphql.tck.apps.basic.api; | ||
|
|
||
| /** | ||
| * Just used as {@code @Source}-object. | ||
| */ | ||
| public class SourceType { | ||
| } |
This file contains hidden or 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,10 @@ | ||
| # SourceTypes | ||
| 1| type Query | source: SourceType | Expecting field source in Query | ||
| 2| type SourceType | stringInput(input: String): String | Expecting field stringInput with parameter input in SourceType | ||
| 3| type SourceType | nonNullStringInput(input: String!): String | Expecting field nonNullStringInput with non-null parameter input in SourceType | ||
| 4| type SourceType | defaultStringInput(input: String = "Default value"): String | Expecting field defaultStringInput with parameter input in SourceType | ||
| 5| type SourceType | dateInput( | ||
| "yyyy-MM-dd" | ||
| input: Date | ||
| ): String | Expecting field dateInput with parameter input in SourceType | ||
| 6| type SourceType | namedStringInput(in: String): String | Expecting field defaultStringInput with parameter `in` in SourceType |
5 changes: 5 additions & 0 deletions
5
server/tck/src/main/resources/tests/sourceWithDateInput/input.graphql
This file contains hidden or 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 testSourceWithDateInput { | ||
| source { | ||
| dateInput(input: "2011-12-03") | ||
| } | ||
| } |
7 changes: 7 additions & 0 deletions
7
server/tck/src/main/resources/tests/sourceWithDateInput/output.json
This file contains hidden or 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 @@ | ||
| { | ||
| "data": { | ||
| "source": { | ||
| "dateInput": "Input was: 2011-12-03" | ||
| } | ||
| } | ||
| } |
5 changes: 5 additions & 0 deletions
5
server/tck/src/main/resources/tests/sourceWithDefaultStringInput/input.graphql
This file contains hidden or 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 testSourceWithDefaultStringInput { | ||
| source { | ||
| defaultStringInput | ||
| } | ||
| } |
7 changes: 7 additions & 0 deletions
7
server/tck/src/main/resources/tests/sourceWithDefaultStringInput/output.json
This file contains hidden or 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 @@ | ||
| { | ||
| "data": { | ||
| "source": { | ||
| "defaultStringInput": "Input was: Default value" | ||
| } | ||
| } | ||
| } |
5 changes: 5 additions & 0 deletions
5
server/tck/src/main/resources/tests/sourceWithNullDateInput/input.graphql
This file contains hidden or 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 testSourceWithNullDateInput { | ||
| source { | ||
| dateInput | ||
| } | ||
| } |
7 changes: 7 additions & 0 deletions
7
server/tck/src/main/resources/tests/sourceWithNullDateInput/output.json
This file contains hidden or 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 @@ | ||
| { | ||
| "data": { | ||
| "source": { | ||
| "dateInput": "Input was: null" | ||
| } | ||
| } | ||
| } |
5 changes: 5 additions & 0 deletions
5
server/tck/src/main/resources/tests/sourceWithNullOnNonNullStringInput/input.graphql
This file contains hidden or 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 testSourceWithNullOnNonNullStringInput { | ||
| source { | ||
| nonNullStringInput | ||
| } | ||
| } |
23 changes: 23 additions & 0 deletions
23
server/tck/src/main/resources/tests/sourceWithNullOnNonNullStringInput/output.json
This file contains hidden or 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,23 @@ | ||
| { | ||
| "data": null, | ||
| "errors": [ | ||
| { | ||
| "message": "Validation error of type MissingFieldArgument: Missing field argument input @ 'source/nonNullStringInput'", | ||
| "locations": [ | ||
| { | ||
| "line": 3, | ||
| "column": 3 | ||
| } | ||
| ], | ||
| "extensions": { | ||
| "description": "Missing field argument input", | ||
| "validationErrorType": "MissingFieldArgument", | ||
| "queryPath": [ | ||
| "source", | ||
| "nonNullStringInput" | ||
| ], | ||
| "classification": "ValidationError" | ||
| } | ||
| } | ||
| ] | ||
| } |
5 changes: 5 additions & 0 deletions
5
server/tck/src/main/resources/tests/sourceWithNullStringInput/input.graphql
This file contains hidden or 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 testSourceWithNullStringInput { | ||
| source { | ||
| stringInput | ||
| } | ||
| } |
7 changes: 7 additions & 0 deletions
7
server/tck/src/main/resources/tests/sourceWithNullStringInput/output.json
This file contains hidden or 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 @@ | ||
| { | ||
| "data": { | ||
| "source": { | ||
| "stringInput": "Input was: null" | ||
| } | ||
| } | ||
| } |
5 changes: 5 additions & 0 deletions
5
server/tck/src/main/resources/tests/sourceWithStringInput/input.graphql
This file contains hidden or 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 testSourceWithStringInput { | ||
| source { | ||
| stringInput(input: "Hello World!") | ||
| } | ||
| } |
7 changes: 7 additions & 0 deletions
7
server/tck/src/main/resources/tests/sourceWithStringInput/output.json
This file contains hidden or 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 @@ | ||
| { | ||
| "data": { | ||
| "source": { | ||
| "stringInput": "Input was: Hello World!" | ||
| } | ||
| } | ||
| } |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.