How to get only selected fields on graphql using javascript

How to get only selected fields on graphql using javascript


-1

I need a basic query to take all users from graphql but only with selected fields such as email, name etc. I couldn’t figure out how it works, aws doc gives example about filtering but it uses id to filter.

   export const getUsers = async () => {
  try {
    const { data } = await API.graphql({
      query: listUsers,
    });
    if (data.listUsers.items) {
      console.log(data.listUsers.items);
      return "data.listUsers.items";
    } else {
      return null;
    }
  } catch (e) {

  }
};

This prints out everything about users but I want only a few fields, how can I filter these fields? I need something around query area but?


Load 4 more related questions


Show fewer related questions

0



Leave a Reply

Your email address will not be published. Required fields are marked *