Skip to content

Commit

Permalink
Merge branch 'main' into dependabot/pip/packages/cfn_guard_rs_hook/ur…
Browse files Browse the repository at this point in the history
…llib3-1.26.18
  • Loading branch information
ericzbeard authored Oct 18, 2023
2 parents aa30f7a + 541a631 commit 5ef0efa
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 7 deletions.
2 changes: 1 addition & 1 deletion hooks/AppSync_BreakingChangeDetection/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@
<dependency>
<groupId>com.graphql-java</groupId>
<artifactId>graphql-java</artifactId>
<version>21.0</version>
<version>21.2</version>
</dependency>
<!-- https://mvnrepository.com/artifact/software.amazon.awssdk/s3 -->
<dependency>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
package com.awscommunity.appsync.breakingchangedetection.schema;

import com.awscommunity.appsync.breakingchangedetection.model.aws.appsync.graphqlschema.AwsAppsyncGraphqlschema;

import graphql.schema.GraphQLSchema;
import graphql.schema.diff.DiffSet;
import graphql.schema.idl.*;
import graphql.schema.diff.SchemaDiff;
import graphql.schema.diff.SchemaDiffSet;
import graphql.schema.idl.RuntimeWiring;
import graphql.schema.idl.SchemaGenerator;
import graphql.schema.idl.SchemaParser;
import graphql.schema.idl.TypeDefinitionRegistry;
import java.util.Objects;
import software.amazon.cloudformation.proxy.AmazonWebServicesClientProxy;
import software.amazon.cloudformation.proxy.Logger;

import java.util.Objects;

import static com.awscommunity.appsync.breakingchangedetection.schema.AppSyncDirectives.APPSYNC_DIRECTIVE_DEFINITIONS;
import static com.awscommunity.appsync.breakingchangedetection.schema.AppSyncScalars.APPSYNC_SCALAR_DEFINITIONS;

Expand All @@ -34,7 +35,7 @@ public static AppSyncSchemaDiffReporter diffSchema(final AwsAppsyncGraphqlschema
final SchemaDiff schemaDiff = new SchemaDiff(SchemaDiff.Options.defaultOptions().enforceDirectives());
final GraphQLSchema currentSchema = getGraphQLSchema(previousResourceProperties, proxy);
final GraphQLSchema newSchema = getGraphQLSchema(resourceProperties, proxy);
final DiffSet diffset = DiffSet.diffSet(currentSchema, newSchema);
final SchemaDiffSet diffset = SchemaDiffSet.diffSetFromSdl(currentSchema, newSchema);

final AppSyncSchemaDiffReporter reporter = new AppSyncSchemaDiffReporter(logger, resourceProperties.getApiId());
schemaDiff.diffSchema(diffset, reporter);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,17 @@ public void handleRequest_BuiltInTypes() throws IOException {
assertResponse(response, OperationStatus.SUCCESS, expectedMessage, null);
}

@Test
public void handleRequest_HiddenDirectiveRemoved() throws IOException {
final ProgressEvent<HookTargetModel, CallbackContext> response = executeSchemaDiffHook(
"original-schema-hidden.graphql",
"original-schema.graphql");

final String expectedMessage = "Breaking changes have been detected for this AWS::AppSync::GraphQLSchema:\n"
+ "API Id: 1 [BREAKING] [MISSING] - The new API does not have a directive named 'hidden' on type 'test'\n";
assertResponse(response, OperationStatus.FAILED, expectedMessage, HandlerErrorCode.NonCompliant);
}

@SuppressWarnings("unchecked")
@Test
public void handleRequest_GetDefinitionFromS3Succeeds() throws IOException {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
type test {
version: String! @hidden
type: TestType
}

type Query {
getTests: [test]!
}

type Mutation {
addTest(version: String!): test
}

enum TestType {
SIMPLE,
COMPLEX
}

0 comments on commit 5ef0efa

Please sign in to comment.