Skip to content

Commit

Permalink
fix(utils): sanitize empty strings as _
Browse files Browse the repository at this point in the history
  • Loading branch information
ardatan committed Feb 13, 2023
1 parent 23dc365 commit d694ccc
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/grumpy-goats-ring.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@graphql-mesh/utils': patch
---

If the field name is empty, put `_` as the name
Original file line number Diff line number Diff line change
Expand Up @@ -86464,6 +86464,8 @@ directive @statusCodeTypeName(typeName: String, statusCode: ID) repeatable on UN

directive @example(value: ObjMap) repeatable on FIELD_DEFINITION | OBJECT | INPUT_OBJECT | ENUM | SCALAR

directive @resolveRootField(field: String) on FIELD_DEFINITION | ARGUMENT_DEFINITION | INPUT_FIELD_DEFINITION

directive @resolveRoot on FIELD_DEFINITION

directive @enum(value: String) on ENUM_VALUE
Expand Down Expand Up @@ -86836,7 +86838,7 @@ type hit @example(value: "{\\"id\\":25684,\\"title\\":\\"American Ninja 5\\",\\"

"Only present if showMatchesPosition = \`true\`. Array of all search query occurrences in all fields."
type mutation_indexes_documents_search_oneOf_0_hits_items__matchesPosition {
: matchesPosition
_: matchesPosition @resolveRootField(field: "")
}

"Starting position and length in bytes of the matched term in the returned value"
Expand Down
4 changes: 4 additions & 0 deletions packages/utils/src/sanitize-name-for-graphql.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,5 +94,9 @@ export function sanitizeNameForGraphQL(unsafeName: string): string {
sanitizedName += '_';
}

if (sanitizedName.length === 0) {
return '_';
}

return sanitizedName;
}

0 comments on commit d694ccc

Please sign in to comment.