atulmy / gql-query-builder

🔧 Simple GraphQL Query Builder
https://npmjs.com/package/gql-query-builder
MIT License
396 stars 43 forks source link

Subscriptions nested fields/operations #87

Open tsukeero opened 12 months ago

tsukeero commented 12 months ago

Using the same query with nested operation on subscription throws an error (works with normal query):

fields: [
                "id",
                {
                    operation: "some_aggregate",
                    fields: [{aggregate: ["count"]}],
                    variables: {
                      varname: {
                        name:"where",
                        type:'some_aggregate_bool_exp!',
                        value: {
                            visible: { _eq: true },
                        }
                      },
                    },
                },
            ],

Uppon quick look at the source it looks they use a different implementation of queryFieldsMap.

The DefaultQueryAdapter.ts is using Utils.queryFieldsMap(this.fields) While the DefaultSubscriptionAdapter is using this.queryFieldsMap(this.fields)](https://github.com/atulmy/gql-query-builder/blob/master/src/adapters/DefaultSubscriptionAdapter.ts#L94C6-L94C40) (which is different and doesn't seem to have nested fields handled correct).

Would the fix be a simple replacement to call the one from utils or is something else I am missing?