Appollo client graphql query by field


We’re trying to a query with appollo client and vuejs to get a specific user via emailAddress (that is the property name).

As a hard-coded example to just get it working I was trying:
var query = gqlbacktick
query oOUser {
oOUser (emailAddress: "[email protected]") {

But it keeps returning back to me an error of:

{errors: [{message: “Unknown argument “emailAddress” on field “oOUser” of type “Query”.”,…},…]}
errors: [{message: “Unknown argument “emailAddress” on field “oOUser” of type “Query”.”,…},…]
0: {message: “Unknown argument “emailAddress” on field “oOUser” of type “Query”.”,…}
locations: [{line: 2, column: 10}]
message: “Unknown argument “emailAddress” on field “oOUser” of type “Query”.”
1: {message: “Field “oOUser” argument “uuid” of type “String!” is required but not provided.”,…}
locations: [{line: 2, column: 3}]
message: “Field “oOUser” argument “uuid” of type “String!” is required but not provided.”

At this point in the workflow, I don’t know the uuid of a user because I’m essentially syncing across multiple platforms. Thoughts?


There’s no way to query for a single object by a field. Instead, you should query the entire collection and get the first returned element. Using your example, I imagine it would look like:

query {
  oOUsers(query: "emailAddress = '[email protected]'" take: 1) {

This will return a collection with 0 or 1 users that have a matching email address. I don’t know if you’re familiar with the GraphQL explorer that is exposed by the Realm GraphQL service, but I’ve found it incredibly useful for building the query before pasting it in the app. It has autocompletion and syntax checks, so it’s super helpful during development.