Merge branch '2.7.x'
This commit is contained in:
@@ -0,0 +1,44 @@
|
||||
/*
|
||||
* Copyright 2012-2021 the original author or authors.
|
||||
*
|
||||
* 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 org.springframework.boot.docs.features.testing.springbootapplications.springgraphqltests;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.docs.web.graphql.GreetingController;
|
||||
import org.springframework.boot.test.autoconfigure.graphql.GraphQlTest;
|
||||
import org.springframework.graphql.test.tester.GraphQlTester;
|
||||
|
||||
@GraphQlTest(GreetingController.class)
|
||||
class GreetingControllerTests {
|
||||
|
||||
@Autowired
|
||||
private GraphQlTester graphQlTester;
|
||||
|
||||
@Test
|
||||
void shouldGreetWithSpecificName() {
|
||||
this.graphQlTester.query("{ greeting(name: \"Alice\") } ").execute().path("greeting").entity(String.class)
|
||||
.isEqualTo("Hello, Alice!");
|
||||
}
|
||||
|
||||
@Test
|
||||
void shouldGreetWithDefaultName() {
|
||||
this.graphQlTester.query("{ greeting } ").execute().path("greeting").entity(String.class)
|
||||
.isEqualTo("Hello, Spring!");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
/*
|
||||
* Copyright 2002-2021 the original author or authors.
|
||||
*
|
||||
* 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 org.springframework.boot.docs.web.graphql;
|
||||
|
||||
import org.springframework.graphql.data.method.annotation.Argument;
|
||||
import org.springframework.graphql.data.method.annotation.QueryMapping;
|
||||
import org.springframework.stereotype.Controller;
|
||||
|
||||
@Controller
|
||||
public class GreetingController {
|
||||
|
||||
@QueryMapping
|
||||
public String greeting(@Argument String name) {
|
||||
return "Hello, " + name + "!";
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
type Query {
|
||||
greeting(name: String! = "Spring"): String!
|
||||
project(slug: ID!): Project
|
||||
}
|
||||
|
||||
""" A Project in the Spring portfolio """
|
||||
type Project {
|
||||
""" Unique string id used in URLs """
|
||||
slug: ID!
|
||||
""" Project name """
|
||||
name: String!
|
||||
""" URL of the git repository """
|
||||
repositoryUrl: String!
|
||||
""" Current support status """
|
||||
status: ProjectStatus!
|
||||
}
|
||||
|
||||
enum ProjectStatus {
|
||||
""" Actively supported by the Spring team """
|
||||
ACTIVE
|
||||
""" Supported by the community """
|
||||
COMMUNITY
|
||||
""" Prototype, not officially supported yet """
|
||||
INCUBATING
|
||||
""" Project being retired, in maintenance mode """
|
||||
ATTIC
|
||||
""" End-Of-Lifed """
|
||||
EOL
|
||||
}
|
||||
Reference in New Issue
Block a user