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

Auto-resolve unresolved aliased fields #283

Merged
merged 3 commits into from
May 31, 2019
Merged

Auto-resolve unresolved aliased fields #283

merged 3 commits into from
May 31, 2019

Conversation

zjbarg
Copy link
Contributor

@zjbarg zjbarg commented May 28, 2019

Adds simple default resolver to aliased fields when no resolver is present.

I'm not sure how to test this properly ( please comment )

#280

@zjbarg
Copy link
Contributor Author

zjbarg commented May 28, 2019

please consider adding a editorconfig file.

@mfn
Copy link
Collaborator

mfn commented May 28, 2019

please consider adding a editorconfig file.

👍 added in b7ec923 !

Copy link
Collaborator

@mfn mfn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Change LGTM too 👍

I'm not sure how to test this properly

Please allow me a bit time to figure this before merging, will get back ASAP!

@zjbarg
Copy link
Contributor Author

zjbarg commented May 30, 2019

Should we have a check that this new resolver only applies when there is a model defined?

@mfn
Copy link
Collaborator

mfn commented May 30, 2019

Label as blocked until #289 can land, after which we can cover the change with a test

mfn added a commit that referenced this pull request May 30, 2019
@mfn
Copy link
Collaborator

mfn commented May 30, 2019

In #289 I've now added the test\Rebing\GraphQL\Tests\Database\SelectFieldsTest::testWithSelectFieldsAndModelAndAlias which I expect will "break" and needs to be adjusted after this PR.

@zjbarg
Copy link
Contributor Author

zjbarg commented May 30, 2019

Yup.

mfn added a commit that referenced this pull request May 31, 2019
@mfn mfn removed the blocked label May 31, 2019
@mfn mfn merged commit b8fdb00 into rebing:master May 31, 2019
mfn added a commit that referenced this pull request May 31, 2019
After #283 landed, this
is now fixed and correctly resolves the alias field.
@mfn
Copy link
Collaborator

mfn commented May 31, 2019

Thanks for the PR!

I've merged this into master and also the recent v1 branch and cut a new v1.22.0 release (hopefully it works 🤞 as expected).

Should we have a check that this new resolver only applies when there is a model defined?

There does not seem to be a technical reason for this yet.

For simple attribute aliases it seems the model is not required. Without it, the generated SQL query will simple not use qualified names. I.e. the difference will be:

  • with model
    select "posts"."id", "posts"."title" from "posts" where "posts"."id" = ? limit 1;
  • without model
    select "id", "title" from "posts" where "posts"."id" = ? limit 1;

But nevertheless it will work correctly; as the SelectFields in general does.

@zjbarg
Copy link
Contributor Author

zjbarg commented May 31, 2019

Thank you @mfn

believe2world added a commit to believe2world/graphql_admin_laravel that referenced this pull request Apr 6, 2023
believe2world added a commit to believe2world/graphql_admin_laravel that referenced this pull request Apr 6, 2023
After rebing/graphql-laravel#283 landed, this
is now fixed and correctly resolves the alias field.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants