question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Generated query response is empty

See original GitHub issue

Is there an existing issue for this?

  • I have searched the existing issues

Product

Strawberry Shake

Describe the bug

Based on Demo project from docs I prepared project pointing to my endpoint and using my query. I’m using .NET 7.

I had to remove JSON scalar from schema because of other bug: https://github.com/ChilliCream/graphql-platform/issues/5899 to make it work.

Repository: https://github.com/kpiekara/crystallize-example/blob/main/Demo

Schema: https://github.com/kpiekara/crystallize-example/blob/main/Demo/schema.graphql

Query: https://github.com/kpiekara/crystallize-example/blob/main/Demo/GetItem.graphql Most interesting part:

query GetItem ($language: String!, $path: String!) {
    catalogue(language: $language, path: $path) {
        ...on Product {
            ...product
            topics {
                path
                name
            }
        }
    }
}

fragment product on Product {
    id
    name
    type
    language
    path

    components {
        ...component
    }

    variants {
        name
        sku
        components {
            ...component
        }
        price
        priceVariants {
            identifier
            name
            price
            currency
        }
        stockLocations {
            identifier
            name
            stock
        }
        isDefault
        images {
            url
            altText
            key

            variants {
                key
                width
                url
            }
        }

        subscriptionPlans {
            identifier
            name
            periods {
                id
                name
                initial {
                    priceVariants {
                        identifier
                        name
                        price
                        currency
                    }
                }
                recurring {
                    priceVariants {
                        identifier
                        name
                        price
                        currency
                    }
                }
            }
        }
    }

    vatType {
        name
        percent
    }
}

Generated client:

[global::System.CodeDom.Compiler.GeneratedCode("StrawberryShake", "13.2.1.0")]
public partial interface IGetItemResult
{
    public global::Demo.IGetItem_Catalogue? Catalogue { get; }
}

[global::System.CodeDom.Compiler.GeneratedCode("StrawberryShake", "13.2.1.0")]
public partial interface IGetItem_Catalogue
{
}

[global::System.CodeDom.Compiler.GeneratedCode("StrawberryShake", "13.2.1.0")]
public partial interface IGetItem_Catalogue_Document : IGetItem_Catalogue
{
}

[global::System.CodeDom.Compiler.GeneratedCode("StrawberryShake", "13.2.1.0")]
public partial interface IGetItem_Catalogue_Folder : IGetItem_Catalogue
{
}

[global::System.CodeDom.Compiler.GeneratedCode("StrawberryShake", "13.2.1.0")]
public partial interface IGetItem_Catalogue_Product : IGetItem_Catalogue
{
    public global::System.Collections.Generic.IReadOnlyList<global::Demo.IGetItem_Catalogue_Topics>? Topics { get; }
}

For code:

var client = services.GetRequiredService<Icatalogue>();
var result = await client.GetItem.ExecuteAsync("", "");
result.EnsureNoErrors();
result.Data.Catalogue.

Catalogue has no properties.

var client = services.GetRequiredService<Icatalogue>();
var result = await client.GetItem.ExecuteAsync("", "");
result.EnsureNoErrors();
(result.Data.Catalogue as IGetItem_Catalogue_Product).

Catalogue has only ‘Topics’ property.

Steps to reproduce

  1. Clone repository
  2. Build

Relevant log output

No response

Additional Context?

No response

Version

13.2.1

Issue Analytics

  • State:open
  • Created 3 months ago
  • Comments:5

github_iconTop GitHub Comments

1reaction
jarlefcommented, Jun 28, 2023

Ah. I misunderstood the issue

One way to resolve this is to replace this

query GetItem ($language: String!, $path: String!) {
    catalogue(language: $language, path: $path) {
        ...on Product {
            ...product
            topics {
                path
                name
            }
        }
    }
}

with

query GetItem ($language: String!, $path: String!) {
    catalogue(language: $language, path: $path) {
             ...product
            topics {
                path
                name
            }
        
    }
}
 [global::System.CodeDom.Compiler.GeneratedCode("StrawberryShake", "13.2.1.0")]
    public partial class GetItem_Catalogue_Product : global::System.IEquatable<GetItem_Catalogue_Product>, IGetItem_Catalogue_Product
    {
        public GetItem_Catalogue_Product(global::System.String id, global::System.String? name, global::System.String? type, global::System.String? language, global::System.String? path, global::System.Collections.Generic.IReadOnlyList<global::Demo.IGetItem_Catalogue_Components>? components, global::System.Collections.Generic.IReadOnlyList<global::Demo.IGetItem_Catalogue_Variants>? variants, global::Demo.IGetItem_Catalogue_VatType? vatType, global::System.Collections.Generic.IReadOnlyList<global::Demo.IGetItem_Catalogue_Topics>? topics)
        {
            Id = id;
            Name = name;
            Type = type;
            Language = language;
            Path = path;
            Components = components;
            Variants = variants;
            VatType = vatType;
            Topics = topics;
        }

        public global::System.String Id { get; }

        public global::System.String? Name { get; }

        public global::System.String? Type { get; }

        public global::System.String? Language { get; }

        public global::System.String? Path { get; }

        public global::System.Collections.Generic.IReadOnlyList<global::Demo.IGetItem_Catalogue_Components>? Components { get; }

        public global::System.Collections.Generic.IReadOnlyList<global::Demo.IGetItem_Catalogue_Variants>? Variants { get; }

        public global::Demo.IGetItem_Catalogue_VatType? VatType { get; }

        public global::System.Collections.Generic.IReadOnlyList<global::Demo.IGetItem_Catalogue_Topics>? Topics { get; }

        public virtual global::System.Boolean Equals(GetItem_Catalogue_Product? other)
        {
            if (ReferenceEquals(null, other))
            {
                return false;
            }

            if (ReferenceEquals(this, other))
            {
                return true;
            }

            if (other.GetType() != GetType())
            {
                return false;
            }

            return (Id.Equals(other.Id)) && ((Name is null && other.Name is null) || Name != null && Name.Equals(other.Name)) && ((Type is null && other.Type is null) || Type != null && Type.Equals(other.Type)) && ((Language is null && other.Language is null) || Language != null && Language.Equals(other.Language)) && ((Path is null && other.Path is null) || Path != null && Path.Equals(other.Path)) && global::StrawberryShake.Internal.ComparisonHelper.SequenceEqual(Components, other.Components) && global::StrawberryShake.Internal.ComparisonHelper.SequenceEqual(Variants, other.Variants) && ((VatType is null && other.VatType is null) || VatType != null && VatType.Equals(other.VatType)) && global::StrawberryShake.Internal.ComparisonHelper.SequenceEqual(Topics, other.Topics);
        }

        public override global::System.Boolean Equals(global::System.Object? obj)
        {
            if (ReferenceEquals(null, obj))
            {
                return false;
            }

            if (ReferenceEquals(this, obj))
            {
                return true;
            }

            if (obj.GetType() != GetType())
            {
                return false;
            }

            return Equals((GetItem_Catalogue_Product)obj);
        }

        public override global::System.Int32 GetHashCode()
        {
            unchecked
            {
                int hash = 5;
                hash ^= 397 * Id.GetHashCode();
                if (Name != null)
                {
                    hash ^= 397 * Name.GetHashCode();
                }

                if (Type != null)
                {
                    hash ^= 397 * Type.GetHashCode();
                }

                if (Language != null)
                {
                    hash ^= 397 * Language.GetHashCode();
                }

                if (Path != null)
                {
                    hash ^= 397 * Path.GetHashCode();
                }

                if (Components != null)
                {
                    foreach (var Components_elm in Components)
                    {
                        hash ^= 397 * Components_elm.GetHashCode();
                    }
                }

                if (Variants != null)
                {
                    foreach (var Variants_elm in Variants)
                    {
                        hash ^= 397 * Variants_elm.GetHashCode();
                    }
                }

                if (VatType != null)
                {
                    hash ^= 397 * VatType.GetHashCode();
                }

                if (Topics != null)
                {
                    foreach (var Topics_elm in Topics)
                    {
                        hash ^= 397 * Topics_elm.GetHashCode();
                    }
                }

                return hash;
            }
        }
    }
0reactions
kpiekaracommented, Jun 28, 2023

I checked and can confirm it works! As I understand this is workaround? Should I close issue since it is resolved for me?

What would happen if I will have a query in future, which will be able to return two types there? This solution will not work?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Simple check for SELECT query empty result - sql
Can anyone point out how to check if a select query returns non empty result set? For example I have next query: SELECT...
Read more >
Is it possible to return empty response if there is no records ...
Is it possible to return empty objects if there is no records in db? db.query(' SELECT * from users where type = $1...
Read more >
SQL-Query is always empty
It works most of the time, until the generated name is different from the one expected.
Read more >
How to return Null or value when nothing is ...
I have a simple query: SELECT name FROM atable WHERE a = 1. I want it to return Null if it finds nothing,...
Read more >
Why do I get zero records when I query my Amazon Athena ...
There are several common reasons why the query might return zero records. Based on your use case, see the related section for common...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found