-
Notifications
You must be signed in to change notification settings - Fork 33
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
omit invalid naptime resource schemas in graphql schema builder #286
Closed
srolel
wants to merge
7
commits into
coursera:master
from
srolel:srolel/naptime-graphql-omit-invalid-schemas
Closed
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
94ad7ef
wip
srolel 599811f
validate schema for each resource individually
srolel fe0408c
make NaptimeRoutes not private
srolel 3fe6516
add test
srolel cce0fc9
Update NaptimePlayRouter.scala
srolel 3171601
Update SangriaGraphQlSchemaBuilderTest.scala
srolel 57389b5
Update SangriaGraphQlSchemaBuilderTest.scala
srolel File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains 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
56 changes: 56 additions & 0 deletions
56
...hql/src/test/scala/org/coursera/naptime/ari/graphql/SangriaGraphQlSchemaBuilderTest.scala
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
package org.coursera.naptime.ari.graphql | ||
|
||
import com.google.inject.Injector | ||
import com.linkedin.data.schema.RecordDataSchema | ||
import org.coursera.naptime.ResourceName | ||
import org.coursera.naptime.ari.FullSchema | ||
import org.coursera.naptime.ari.LocalSchemaProvider | ||
import org.coursera.naptime.ari.SchemaProvider | ||
import org.coursera.naptime.ari.graphql.models.MergedCourse | ||
import org.coursera.naptime.ari.graphql.models.MergedInstructor | ||
import org.coursera.naptime.ari.graphql.models.MergedPartner | ||
import org.coursera.naptime.ari.graphql.models.RecordWithUnionTypes | ||
import org.coursera.naptime.model.Keyed | ||
import org.coursera.naptime.router2.NaptimeRoutes | ||
import org.coursera.naptime.router2.ResourceRouterBuilder | ||
import org.coursera.naptime.schema.Handler | ||
import org.coursera.naptime.schema.HandlerKind | ||
import org.coursera.naptime.schema.Parameter | ||
import org.coursera.naptime.schema.Resource | ||
import org.coursera.naptime.schema.ResourceKind | ||
import org.junit.Test | ||
import org.mockito.Mockito._ | ||
import org.scalatest.junit.AssertionsForJUnit | ||
import org.scalatest.mockito.MockitoSugar | ||
|
||
class SangriaGraphQlSchemaBuilderTest extends AssertionsForJUnit { | ||
@Test | ||
def badResourceSchemaOmitFromGraphqlSchema(): Unit = { | ||
val schemaTypes = Map( | ||
"org.coursera.naptime.ari.graphql.models.MergedCourse" -> MergedCourse.SCHEMA, | ||
"org.coursera.naptime.ari.graphql.models.FakeModel" -> RecordWithUnionTypes.SCHEMA, | ||
"org.coursera.naptime.ari.graphql.models.MergedPartner" -> MergedPartner.SCHEMA, | ||
"org.coursera.naptime.ari.graphql.models.MergedInstructor" -> MergedInstructor.SCHEMA | ||
) | ||
val resourcesWithInvalidResource = | ||
Set( | ||
Models.courseResource.copy(version = Some(-1)), | ||
Models.instructorResource, | ||
Models.partnersResource, | ||
Models.fakeModelResource | ||
) | ||
val builder = new SangriaGraphQlSchemaBuilder(resourcesWithInvalidResource, schemaTypes) | ||
val schema = builder.generateSchema().data | ||
|
||
val allResources2 = | ||
Set( | ||
Models.instructorResource, | ||
Models.partnersResource, | ||
Models.fakeModelResource | ||
) | ||
val builder2 = new SangriaGraphQlSchemaBuilder(allResources2, schemaTypes) | ||
val schema2 = builder2.generateSchema().data | ||
|
||
assertResult(schema2.renderPretty)(schema.renderPretty) | ||
} | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think we should have references to our internal tools in the OSS repo.
Should this be an option? We should maintain compatibility with existing integrations. Alternatively, we could potentially have a 2nd implementation to provide this functionality.