graphql.schema.idl.UnExecutableSchemaGenerator Java Examples
The following examples show how to use
graphql.schema.idl.UnExecutableSchemaGenerator.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: GraphQLAPIHandler.java From carbon-apimgt with Apache License 2.0 | 5 votes |
/** * This method validate the payload * * @param messageContext message context of the request * @param document graphQL schema of the request * @return true or false */ private boolean validatePayloadWithSchema(MessageContext messageContext, Document document) { ArrayList<String> validationErrorMessageList = new ArrayList<>(); List<ValidationError> validationErrors; String validationErrorMessage; synchronized (apiUUID + CLASS_NAME_AND_METHOD) { if (schema == null) { Entry localEntryObj = (Entry) messageContext.getConfiguration().getLocalRegistry().get(apiUUID + GRAPHQL_IDENTIFIER); if (localEntryObj != null) { SchemaParser schemaParser = new SchemaParser(); schemaDefinition = localEntryObj.getValue().toString(); TypeDefinitionRegistry registry = schemaParser.parse(schemaDefinition); schema = UnExecutableSchemaGenerator.makeUnExecutableSchema(registry); } } } validationErrors = validator.validateDocument(schema, document); if (validationErrors != null && validationErrors.size() > 0) { if (log.isDebugEnabled()) { log.debug("Validation failed for " + document); } for (ValidationError error : validationErrors) { validationErrorMessageList.add(error.getDescription()); } validationErrorMessage = String.join(",", validationErrorMessageList); handleFailure(messageContext, validationErrorMessage); return false; } return true; }
Example #2
Source File: FederationSdlPrinter.java From federation-jvm with MIT License | 2 votes |
/** * This can print an in memory GraphQL IDL document back to a logical schema definition. * If you want to turn a Introspection query result into a Document (and then into a printed * schema) then use {@link graphql.introspection.IntrospectionResultToSchema#createSchemaDefinition(java.util.Map)} * first to get the {@link graphql.language.Document} and then print that. * * @param schemaIDL the parsed schema IDL * @return the logical schema definition */ public String print(Document schemaIDL) { TypeDefinitionRegistry registry = new SchemaParser().buildRegistry(schemaIDL); return print(UnExecutableSchemaGenerator.makeUnExecutableSchema(registry)); }