Contentful logo

Contentful Community

Does the .NET SDK have GraphQL?

We use .NET SDK and I can’t find any methods to use for GraphQL.
I try this

public async Task<ContentfulCollection<TDynamic>>? GetEntriesByQueryAsync<TDynamic>(string queryString)
        {
            try
            {
                return await _client.GetEntries<TDynamic>(queryString);
            }
            catch (Exception ex)
            {
                var desc = ex;
                return default;
            }
        }

But it doesn’t work.

I had a similar issue with another CMS. In the end, I preferred to write my own typed HTTP client for everything rather than using the SDK. It was not very hard, and GraphQL was actually an easy part, but still…I prefer to query a search index and get the JSON from that rather than from the CMS. Even with CMS, I prefer to know the HTTP APIs and only expose to my code the APIs that I need, otherwise switching to a different CMS is even more of a challenge. You might be able to extend the SDK with GraphQL, or just do something on your own. I think you might find a lot of value in writing your own code rather than using the SDK.

1 Like

Thank you very much for your answer, and that’s what I did. I work through HttpClient.