Skip to content

Be able to make GraphQLRequest.list that only include certain attributesΒ #3882

@concavegit

Description

@concavegit

Is your feature request related to a problem? Please describe.

I am trying to create a query that lists just the owners of each item in a schema, like this:

let request = GraphQLRequest<MyModel>.list(MyModel.self)

I was trying to find a way to only include the owner using includes, like this

let request = GraphQLRequest<MyModel>.list(MyModel.self, includes: { myModel -> myModel.owner })

but from the documentation and type errors, includes is just to include relations and not attributes.

Being able to query by fields is important because some fields may not be readable by all users. The only way to make a list query in this case would be to only query fields that the user does have access to.

Describe the solution you'd like

I'd like something like GraphQLRequest<MyModel>.list(MyModel.self, attributes: [my_list_of_attributes]), or more realistically attributes: ModelPath -> [FieldPath].

Describe alternatives you've considered

I am guessing this is technically possible by using a lower level function using ModelBasedGraphQLDocumentBuilder. If that is the solution you recommend, could you provide some documentation for it?

Is the feature request related to any of the existing Amplify categories?

No response

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    apiIssues related to the API categoryfeature-requestRequest a new feature

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions