Created
June 1, 2018 08:44
-
-
Save aSemy/851bb742f1413ec08b12547a3b7e0ff7 to your computer and use it in GitHub Desktop.
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
@Autowired | |
public GraphQlSampleController(final GraphQLRuleService ruleService) { | |
// Schema generated from query classes | |
GraphQLSchema schemaFromAnnotated = new GraphQLSchemaGenerator()// | |
// setup the schema | |
// ... | |
.generate(); | |
// set up field validation | |
CustomFieldValidation fieldValidation = new CustomFieldValidation(); | |
fieldValidation | |
// add rules for when user is registering | |
.addRules(ExecutionPath.parse("/userRegister"), UserRegisterRequest.getRules(ruleService)) | |
; | |
FieldValidationInstrumentation instrumentation = new FieldValidationInstrumentation(fieldValidation); | |
// add rules to the schema | |
graphQlFromAnnotated = GraphQL.newGraphQL(schemaFromAnnotated)// | |
.instrumentation(instrumentation)// | |
.build(); | |
LOGGER.info("Generated GraphQL schema using SPQR"); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment