Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Supporting casting or object type filtering for groups membership #836

Closed
will-bartlett opened this issue Nov 8, 2020 · 4 comments
Closed
Assignees
Labels
Kiota Is solved by Kiota or will be addressed in Kiota OData Cast P1 Request: enhancement
Milestone

Comments

@will-bartlett
Copy link

will-bartlett commented Nov 8, 2020

I'd like .NET Graph SDK to support the full features of Graph (or, alternatively, I can't find the docs for what I need). I'd like to make a request to:

https://graph.microsoft.com/v1.0/groups/{groupId}/members/microsoft.graph.group

OR

https://graph.microsoft.com/v1.0/groups/{groupId}/members?$filter=isof('microsoft.graph.group')

That is - I'd like to look at group membership, but filtered to only groups (ignoring users). The "isof" selector here is supported by the client library, but not the server. And, the casting ("/microsoft.graph.group") appears to be supported on the server but not in the client library. For this request, Graph Explorer shows sample code for .NET that corresponds to:

https://graph.microsoft.com/v1.0/groups/{groupId}/members

I experimented a little with the SDK based on some of the code in depot and eventually wrote:

            var originalUrl = GraphClient
                .Groups[groupId]
                .Members
                .RequestUrl;

            Type t = typeof(Group);

            return new GroupMembersCollectionWithReferencesRequestBuilder($"{originalUrl}/{t.FullName}", GraphClient)
                .Request();

This way, the SDK would make the request, but deserialization was problematic. Because the Graph API does not return an @odata.type when it's specified by the caller, the .NET Graph SDK deserialized the response objects as if they were generic DirectoryObjects rather than Groups, which is not productive.

Describe the solution you'd like
I'd like to be able to write something like:

GraphClient
    .Groups[groupId]
    .Members
    .Cast<Group>()
    .Request();

Describe alternatives you've considered
I'll probably just not filter my results (extra bandwidth / latency, but the feature works).
AB#6678

@MIchaelMainer
Copy link
Contributor

This feature request needs to be implemented similar to what we have in Java.

@andrueastman
Copy link
Member

This is tracked via microsoftgraph/MSGraph-SDK-Code-Generator#239

@maisarissi maisarissi added OData Cast Kiota Is solved by Kiota or will be addressed in Kiota Epic and removed promote Epic labels Feb 18, 2022
@maisarissi
Copy link
Contributor

This will be addressed in Kiota via microsoft/kiota#648

@andrueastman andrueastman added this to the 5.0.0 milestone May 6, 2022
@andrueastman andrueastman self-assigned this May 25, 2022
@andrueastman
Copy link
Member

With the latest V5 preview version, this should now be possible to do with code similar to this.

var usersInGroup = await graphServiceClient.Groups["group-id"].Members.User.GetAsync();

More information is also available in the upgrade guide here.

@ghost ghost locked as resolved and limited conversation to collaborators Jul 2, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Kiota Is solved by Kiota or will be addressed in Kiota OData Cast P1 Request: enhancement
Projects
None yet
Development

No branches or pull requests

4 participants