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

Note: when using connections with a (first:n) directive to resolve relations #9

Open
geneeblack opened this issue Nov 16, 2017 · 0 comments

Comments

@geneeblack
Copy link

when using graphql connections to resolve relations and a limit is specified on the connection, n+1 queries are still employed on the relation even though the primary query successfully batches the query.

given the following query:

query {
  log {
    items {
      edges {
        node {
          files {
            edges {
              node {
                id
              }
            }
          }
        }
      }
    }
  }
}

the preloads limit the result query to 1 query

but if specifying a limit (explicitly or default using GraphQL schema setting default_max_page_size)

query {
  log {
    items {
      edges {
        node {
          files(first:2) {
            edges {
              node {
                id
              }
            }
          }
        }
      }
    }
  }
}

the batch is successfully done to build the initial log items with its associated files, but then n+1 queries are done to the files applying the limit specified. I'm not sure if there is any way to prevent this since it appears it is being generated from GraphQL-ruby

SELECT 
	`log`.`id` AS t0_r0,
FROM
	`log`
LEFT OUTER JOIN
	`files` ON `log`.`id` = `files`.`log_id`
WHERE
		`log`.`id` IN (230811);
		
File Load (0.4ms)  SELECT  `files`.* FROM `files` WHERE `files`.`log_id` = 230811 LIMIT 2 

I just wanted to let you know if you weren't already aware.

@geneeblack geneeblack changed the title Note: when using connections to resolve relations Note: when using connections with a (first:n) directive to resolve relations Nov 16, 2017
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

No branches or pull requests

1 participant