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

"Sorting on fields that need arguments to resolve is deprecated" warning #28565

Closed
cedricdelpoux opened this issue Dec 9, 2020 · 14 comments
Closed
Labels
status: needs reproduction This issue needs a simplified reproduction of the bug for further troubleshooting. topic: GraphQL Related to Gatsby's GraphQL layer type: bug An issue or pull request relating to a bug in Gatsby

Comments

@cedricdelpoux
Copy link

Description

If I create a node field using createNodeField from a node value:

exports.onCreateNode = async ({node, actions: {createNodeField}}) => {
  if (node.internal.type === "MarkdownRemark") {
    createNodeField({
      node,
      name: "template",
      value:  node.frontmatter.template,
    })
  }
}

Then I want to use this field to group my nodes

query MyQuery {
  allMarkdownRemark {
    group(field: fields___template) {
      fieldValue
      totalCount
    }
  }
}

There is the following warning
Screenshot 2020-12-09 at 17 19 30

If I use the original data (which is the same), everything is fine

query MyQuery {
  allMarkdownRemark {
    group(field: frontmatter___template) {
      fieldValue
      totalCount
    }
  }
}

Steps to reproduce

  1. Create a node field
  2. Try to group nodes by this field

Expected result

No warning, it should works

Actual result

Sorting on fields that need arguments to resolve is deprecated

Environment

System:
OS: macOS 11.0.1
CPU: (4) x64 Intel(R) Core(TM) i5-4258U CPU @ 2.40GHz
Shell: 5.8 - /bin/zsh
Binaries:
Node: 15.2.1 - /usr/local/bin/node
Yarn: 1.22.10 - /usr/local/bin/yarn
npm: 7.0.10 - /usr/local/bin/npm
Languages:
Python: 2.7.16 - /usr/bin/python
Browsers:
Chrome: 87.0.4280.88
Firefox: 72.0.2
Safari: 14.0.1
npmPackages:
gatsby: ^2.28.0 => 2.28.0

@cedricdelpoux cedricdelpoux added the type: bug An issue or pull request relating to a bug in Gatsby label Dec 9, 2020
@gatsbot gatsbot bot added the status: triage needed Issue or pull request that need to be triaged and assigned to a reviewer label Dec 9, 2020
@vladar
Copy link
Contributor

vladar commented Dec 10, 2020

Hey @cedricdelpoux

Do you use schema customization by chance? If so, double check that you don't have arguments defined for this field (e.g. by checking the field MarkdownRemarkFields.template in GraphiQL docs).

If you are absolutely positive that this field has no arguments - please provide a minimal reproduction and we'll be able to take another look.

@vladar vladar added status: needs reproduction This issue needs a simplified reproduction of the bug for further troubleshooting. topic: GraphQL Related to Gatsby's GraphQL layer and removed status: triage needed Issue or pull request that need to be triaged and assigned to a reviewer labels Dec 10, 2020
@cedricdelpoux
Copy link
Author

Screenshot 2020-12-10 at 14 42 12

Like you can see, it's a simple string

@vladar
Copy link
Contributor

vladar commented Dec 11, 2020

Interesting. Can you provide a minimal reproduction. I'll take a look.

@sonapraneeth-a
Copy link
Contributor

I've seen a similar warning when using sort. I've been using sort based on example provided in the docs

By the way, the fields I'm using are from schema customization. Is there any way to use fields created by schema customization in sort?

image

image

@github-actions
Copy link

github-actions bot commented Jan 1, 2021

Hiya!

This issue has gone quiet. Spooky quiet. 👻

We get a lot of issues, so we currently close issues after 60 days of inactivity. It’s been at least 20 days since the last update here.
If we missed this issue or if you want to keep it open, please reply here.
As a friendly reminder: the best way to see this issue, or any other, fixed is to open a Pull Request. Check out gatsby.dev/contribute for more information about opening PRs, triaging issues, and contributing!

Thanks for being a part of the Gatsby community! 💪💜

@github-actions github-actions bot added the stale? Issue that may be closed soon due to the original author not responding any more. label Jan 1, 2021
@cedricdelpoux cedricdelpoux changed the title Group nodes with a field throw warning "Sorting on fields that need arguments to resolve is deprecated" warning Jan 1, 2021
@amantiwari1
Copy link

amantiwari1 commented Jan 31, 2021

I've seen a similar warning, is any way to fix it?

image

@github-actions github-actions bot removed the stale? Issue that may be closed soon due to the original author not responding any more. label Jan 31, 2021
@vladar
Copy link
Contributor

vladar commented Feb 9, 2021

This is possible if there are custom arguments on those fields. But it doesn't look this way from your screenshots. I checked it on our starters and I don't see this problem. So we do need a minimal reproduction to actually start investigating this.

@sonapraneeth-a
Copy link
Contributor

@vladar , What does custom argument mean? Could you please show an example?

@ascorbic
Copy link
Contributor

Hi. I'm going to close this now, as we can't do much to help without a reproduction. If you are able to create a minimal reproduction for this then please do reopen the issue. Thanks!

@emmenko
Copy link

emmenko commented Mar 6, 2021

The "minimal blog theme" from @LekoArts uses those deprecated sorting fields:

https://github.com/LekoArts/gatsby-themes/blob/ea3eb0b4f6d49c99b2f209d0a9a504f3e3f1ce10/themes/gatsby-theme-minimal-blog-core/gatsby-node.js#L295-L299

I'm curious to hear from @LekoArts what's the best way to migrate to v3 and avoid those deprecation warnings, while keeping the same functionality.

Thanks 🙏

@rejas
Copy link

rejas commented May 21, 2021

I get this warning too when building my personal homepage (https://github.com/rejas/veeck.de)

Will try to get a minimal reproduction done....

@rejas
Copy link

rejas commented May 21, 2021

hi @ascorbic I created a repo with hopefully minimal code around it. You can find it in https://github.com/rejas/deprecate_repo

or should I open a new issue with this sicne I am not the OP ? Thx in advance

@ascorbic
Copy link
Contributor

Hi @rejas,
I don't work at Gatsby anymore, but I'd say open a new issue as this one has been closed.

@rejas
Copy link

rejas commented May 21, 2021

Will do, thanks anyway!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: needs reproduction This issue needs a simplified reproduction of the bug for further troubleshooting. topic: GraphQL Related to Gatsby's GraphQL layer type: bug An issue or pull request relating to a bug in Gatsby
Projects
None yet
Development

No branches or pull requests

7 participants