Skip to content

Commit

Permalink
Do not expose unsupported queries in the GraphQL schema. (#16134)
Browse files Browse the repository at this point in the history
Co-authored-by: Hisham Bin Ateya <[email protected]>
  • Loading branch information
gvkries and hishamco authored May 26, 2024
1 parent 9f4229b commit 5df6599
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public async Task BuildAsync(ISchema schema)

var fieldTypeName = querySchema["fieldTypeName"]?.ToString() ?? query.Name;

if (type.StartsWith("ContentItem/", StringComparison.OrdinalIgnoreCase))
if (query.ReturnDocuments && type.StartsWith("ContentItem/", StringComparison.OrdinalIgnoreCase))
{
var contentType = type.Remove(0, 12);
fieldType = BuildContentTypeFieldType(schema, contentType, query, fieldTypeName);
Expand All @@ -86,7 +86,7 @@ public async Task BuildAsync(ISchema schema)

private static FieldType BuildSchemaBasedFieldType(SqlQuery query, JsonNode querySchema, string fieldTypeName)
{
var properties = querySchema["properties"].AsObject();
var properties = querySchema["properties"]?.AsObject();
if (properties == null)
{
return null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,7 @@ public async Task BuildAsync(ISchema schema)

private static FieldType BuildSchemaBasedFieldType(ElasticQuery query, JsonNode querySchema, string fieldTypeName)
{
var properties = querySchema["properties"].AsObject();

var properties = querySchema["properties"]?.AsObject();
if (properties == null)
{
return null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ public async Task BuildAsync(ISchema schema)

private static FieldType BuildSchemaBasedFieldType(LuceneQuery query, JsonNode querySchema, string fieldTypeName)
{
var properties = querySchema["properties"].AsObject();
var properties = querySchema["properties"]?.AsObject();
if (properties == null)
{
return null;
Expand Down

0 comments on commit 5df6599

Please sign in to comment.