Skip to content

Commit

Permalink
* spring configuration namespace updated to have graphql root node
Browse files Browse the repository at this point in the history
* update README
* update `GraphWebAutoConfiguration` to rely on a new properties namespace
  • Loading branch information
oembedler committed Mar 29, 2016
1 parent 97bf473 commit 5f72343
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 43 deletions.
37 changes: 17 additions & 20 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -142,26 +142,23 @@ Server can host multiple schemas (all are registered at the startup time).
To run query against particular schema - HTTP header `graphql-schema` parameter passed along with the query should contain graphql schema name of interest.

```yaml
spring:
application:
name: graphql-todo-app
graphql:
server:
mapping: /graphql
corsEnabled: true
suppressSpringResponseCodes: true
query-key: query
variables-key: variables
uploadMaxFileSize: 128KB
uploadMaxRequestSize: 128KB
schema:
clientMutationIdName: clientMutationId
injectClientMutationId: true
allowEmptyClientMutationId: false
mutationInputArgumentName: input
outputObjectNamePrefix: Payload
inputObjectNamePrefix: Input
schemaMutationObjectName: Mutation
graphql:
server:
mapping: /graphql
corsEnabled: true
suppressSpringResponseCodes: true
query-key: query
variables-key: variables
uploadMaxFileSize: 128KB
uploadMaxRequestSize: 128KB
schema:
clientMutationIdName: clientMutationId
injectClientMutationId: true
allowEmptyClientMutationId: false
mutationInputArgumentName: input
outputObjectNamePrefix: Payload
inputObjectNamePrefix: Input
schemaMutationObjectName: Mutation
```
To facilitate access from Nodejs frontend to GraphQL backend by default system enables global CORS filter for `/graphql/**` context.
Expand Down
36 changes: 18 additions & 18 deletions graphql-sample-app/src/main/resources/application.yml
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
spring:
application:
name: graphql-todo-app
graphql:
server:
mapping: /graphql
corsEnabled: true
suppressSpringResponseCodes: true
query-key: query
variables-key: variables
uploadMaxFileSize: 128KB
uploadMaxRequestSize: 128KB
schema:
clientMutationIdName: clientMutationId
injectClientMutationId: true
allowEmptyClientMutationId: false
mutationInputArgumentName: input
outputObjectNamePrefix: Payload
inputObjectNamePrefix: Input
schemaMutationObjectName: Mutation
server:
port: 9000
port: 9000
graphql:
server:
mapping: /graphql
corsEnabled: true
suppressSpringResponseCodes: true
query-key: query
variables-key: variables
uploadMaxFileSize: 128KB
uploadMaxRequestSize: 128KB
schema:
clientMutationIdName: clientMutationId
injectClientMutationId: true
allowEmptyClientMutationId: false
mutationInputArgumentName: input
outputObjectNamePrefix: Payload
inputObjectNamePrefix: Input
schemaMutationObjectName: Mutation
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
* @author <a href="mailto:[email protected]">oEmbedler Inc.</a>
*/
@Configuration
@ConfigurationProperties(prefix = "spring.graphql")
@ConfigurationProperties(prefix = "graphql")
public class GraphQLProperties {

@NestedConfigurationProperty
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
* @author <a href="mailto:[email protected]">oEmbedler Inc.</a>
*/
@RestController
@RequestMapping("${spring.graphql.server.mapping:/graphql}")
@RequestMapping("${graphql.server.mapping:/graphql}")
public class GraphQLServerController {

private static final Logger LOGGER = LoggerFactory.getLogger(GraphQLServerController.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,11 @@ public class GraphQLWebAutoConfiguration {
private static final String DEFAULT_UPLOAD_MAX_FILE_SIZE = "128KB";
private static final String DEFAULT_UPLOAD_MAX_REQUEST_SIZE = "128KB";

@Value("${spring.graphql.server.mapping:/graphql}")
@Value("${graphql.server.mapping:/graphql}")
private String graphQLServerMapping;

@Bean
@ConditionalOnProperty(value = "spring.graphql.server.corsEnabled", havingValue = "true", matchIfMissing = true)
@ConditionalOnProperty(value = "graphql.server.corsEnabled", havingValue = "true", matchIfMissing = true)
public WebMvcConfigurer corsConfigurer() {
return new WebMvcConfigurerAdapter() {
@Override
Expand All @@ -71,7 +71,7 @@ public GraphQLServerController basicGraphQLController() {

@Bean
@ConditionalOnMissingBean(GlobalDefaultExceptionHandler.class)
@ConditionalOnProperty(value = "spring.graphql.server.suppressSpringResponseCodes", havingValue = "true", matchIfMissing = true)
@ConditionalOnProperty(value = "graphql.server.suppressSpringResponseCodes", havingValue = "true", matchIfMissing = true)
public GlobalDefaultExceptionHandler globalDefaultExceptionHandler() {
return new GlobalDefaultExceptionHandler();
}
Expand Down

0 comments on commit 5f72343

Please sign in to comment.