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

DSHttpAdapter#find/create/update/destroy do not call queryTransform #313

Closed
jessemorton opened this issue Mar 4, 2015 · 6 comments
Closed
Assignees

Comments

@jessemorton
Copy link

Per discussion at https://groups.io/org/groupsio/jsdata/thread/40098 it's expected that DS#find will run the (optionally) passed params object through DSHttpAdapterProvider.defaults.queryTransform like how DS#findAll does. Currently this does not happen.

@jmdobry jmdobry changed the title DS#find does not call queryTransform DSHttpAdapter#find does not call queryTransform Mar 5, 2015
@jmdobry jmdobry changed the title DSHttpAdapter#find does not call queryTransform DSHttpAdapter#find/create/update/destroy do not call queryTransform Mar 5, 2015
@jmdobry jmdobry self-assigned this Mar 5, 2015
@jmdobry jmdobry closed this as completed in 05c4e7a Mar 5, 2015
@MikaAK
Copy link

MikaAK commented Mar 9, 2015

I seem to still be having this problem. In my config block I've defined adeserialize and transformQuery function, but no console.log gets hit. Is there anything I'm missing? I'm on V2.2.2! If anyone knows what I can do that would be great!

DSHttpAdapterProvider.defaults.deserialize = (resourceName, data) => {
    console.log(resourceName, data)
    return data ? ('data' in data ? data.data : data) : data;
}

DSHttpAdapterProvider.defaults.queryTransform = (params) => {
    console.log(params, 'transform')
    return params
}

@jmdobry
Copy link
Member

jmdobry commented Mar 9, 2015

The signature for queryTransform is actually queryTransform(resource, params) not queryTransform(params).

As you can see here queryTransform is called in DSHttpAdapter#find. You'll find similar code in the other methods.

Could you possibly create a jsfiddle, plunker or jsbin that demonstrates the issue? What version of js-data are you using? Are you using any other js-data libraries?

@MikaAK
Copy link

MikaAK commented Mar 9, 2015

Ah I found the problem. queryTransform isn't called when you define extra default actions under DSProvider.defaults.

@jmdobry
Copy link
Member

jmdobry commented Mar 9, 2015

Ah, that's because a generated action uses DSHttpAdapter#GET or #POST, etc., which don't call queryTransform.

@MikaAK
Copy link

MikaAK commented Mar 10, 2015

Wouldn't it be better if they did? Unless there's another way, new actions can't get transformed and also return a full structure instead of the data since deserialize is also not called.

@jmdobry
Copy link
Member

jmdobry commented Mar 10, 2015

I tend to agree, though at this point I'm not sure that if add queryTransform to those methods it wouldn't be a breaking change for some people.

@jmdobry jmdobry added done and removed in progress labels Mar 18, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants