Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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);
}

}
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 {
}
10 changes: 10 additions & 0 deletions server/tck/src/main/resources/tests/sourceSchemaTests.csv
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
query testSourceWithDateInput {
source {
dateInput(input: "2011-12-03")
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"data": {
"source": {
"dateInput": "Input was: 2011-12-03"
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
query testSourceWithDefaultStringInput {
source {
defaultStringInput
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"data": {
"source": {
"defaultStringInput": "Input was: Default value"
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
query testSourceWithNullDateInput {
source {
dateInput
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"data": {
"source": {
"dateInput": "Input was: null"
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
query testSourceWithNullOnNonNullStringInput {
source {
nonNullStringInput
}
}
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"
}
}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
query testSourceWithNullStringInput {
source {
stringInput
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"data": {
"source": {
"stringInput": "Input was: null"
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
query testSourceWithStringInput {
source {
stringInput(input: "Hello World!")
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"data": {
"source": {
"stringInput": "Input was: Hello World!"
}
}
}