graphqlmongodb-atlasresolver

How to write resolver for hyphenated field in Atlas App Services schema?


I have an App Service running on MongoDB Atlas, I'd like to know how I can get rid of a hyphenated field using a custom resolver, as I can't query it in GraphQL since it causes a syntax error.

I found a similar problem linked below, but I'd like to know how to implement the equivalent in Atlas.

How to handle hyphens in GraphQL Schema definitions

"stuff": {
      "bsonType": "object",
      "properties": {
        "hyphenated-field-is-causing-problems": {
          "bsonType": "object",
          "properties": {
            "data": {
              "bsonType": "string"
            }
        }    
    }
}


Solution

  • Answered my own question. Turns out if you omit the hyphens, it works the same.

    query {
        stuff {
          hyphenatedfieldiscausingproblems {
            data
          }
        }
      }
    }