# Dynamic pull selector

**URL:** <https://forum.datomic.com/t/dynamic-pull-selector/478>\
**Category:** Client API\
**Created:** [June 20, 2018, 10:52am UTC](https://forum.datomic.com/t/dynamic-pull-selector/478 "2018-06-20T10:52:47Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Robin](https://sea2.discourse-cdn.com/flex016/user_avatar/forum.datomic.com/robin/32/173_2.png) [@Robin](https://forum.datomic.com/u/Robin)\
**Post date:** [June 20, 2018, 10:52am UTC](https://forum.datomic.com/t/dynamic-pull-selector/478/1 "2018-06-20T10:52:47Z")

</div>

I wan’t to pass inn a pull selector as an argument to a query, like this:

```auto
(d/q '[:find (pull ?e ?fields)
         :in $ ?fields
         :where [?e :game/name _]] 
  (d/db conn) [:db/id :game/name])

```

But this results in a “Invalid pull syntax” exception. The alternative (which I’m doing now) is to use the find query to get out all the entity ids I’m interested in, and then running pull on each of those ids. But since I’m using the client.api, that would result in a lot of overhead in communicating with the peer server, right?

Is there a way to pass in the pull selector dynamically that I’ve missed in the documentation?

---

<div class="post-metadata">

**Author:** ![Folcon](https://sea2.discourse-cdn.com/flex016/user_avatar/forum.datomic.com/folcon/32/175_2.png) [@Folcon](https://forum.datomic.com/u/Folcon)\
**Post date:** [June 20, 2018, 11:25am UTC](https://forum.datomic.com/t/dynamic-pull-selector/478/2 "2018-06-20T11:25:48Z")

</div>

Hey @Robin, poking around the query I got this to work:

> (d/q '[:find (pull ?e fields)  
> :in $ fields  
> :where [?e :game/name \_]]  
> (d/db conn) '[\*])

Which can be rewritten as:

> (d/q '[:find (pull ?e fields)  
> :in $ fields  
> :where [?e :game/name \_]]  
> (d/db conn) '[:db/id :game/name])

Not sure why though =)…

Hope it helps!

---

<div class="post-metadata">

**Author:** ![james](https://avatars.discourse-cdn.com/v4/letter/j/bc8723/32.png) [@james](https://forum.datomic.com/u/james)\
**Post date:** [October 1, 2018, 7:28pm UTC](https://forum.datomic.com/t/dynamic-pull-selector/478/3 "2018-10-01T19:28:33Z")

</div>

I’m sure you’ve figured this out since June, but in case someone else encounters this:

You can pass pull expressions as arguments to a query, but you don’t prefix a `?`. That’s reserved for logic variables, or something. Renaming `?fields` to `fields` should fix this.
