Skip to content

Commit

Permalink
Ignore non-graphql files (#1502)
Browse files Browse the repository at this point in the history
* Ignore non-GraphQL files

* Ignore non-GraphQL files

* Add query to schemas for testing

* Fix lint error

* Use filename instead of toString()

* Rename variable

* Cleanup code

---------

Co-authored-by: Grace <gding@netflix.com>
  • Loading branch information
Grace Ding and gracecding committed May 4, 2023
1 parent 1ffc1ca commit c76dd0c
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -547,7 +547,8 @@ class DgsSchemaProvider(
}

schemas += metaInfSchemas
return schemas

return schemas.filter { it.filename.endsWith(".graphql", true) || it.filename.endsWith(".graphqls", true) }
}

companion object {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,22 @@ internal class DgsSchemaProviderTest {
).findSchemaFiles()
}

@Test
fun findSchemaFilesIgnoreNonGraphQLFiles() {
val schemaFiles = schemaProvider(
schemaLocations = listOf("classpath*:location3/**/*.graphql*")
).findSchemaFiles()
assertEquals("location3-schema1.graphql", schemaFiles[0].filename)
assertEquals("location3-schema2.graphqls", schemaFiles[1].filename)

// Check that the .graphqlconfig file has been ignored
val schemaFilesNames: MutableList<String> = mutableListOf()
for (schemaFile in schemaFiles) {
schemaFilesNames.add(schemaFile.filename)
}
assert(!schemaFilesNames.contains("location3-ignore.graphqlconfig"))
}

@Test
fun addFetchers() {
val fetcher = object : Any() {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
type Query {
hello(name:String): String
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
type Query {
hello(name:String): String
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
type Query {
hello(name:String): String
}

0 comments on commit c76dd0c

Please sign in to comment.