Comments (4)
I'm not sure I understand. Absinthe.Ecto doesn't explicitly use the primary key, or any other key at all. It relies entirely on your Ecto associations.
from absinthe_ecto.
Thanks for getting back to me @benwilson512. I believe this was user error. I was attempting to handle associations from a database that started its life as Drupal; which has a mixture of unconventional primary keys and foreign keys.
To simplify things, I created a test scenario that required custom foreign keys, and all went well (eerily well, actually). It looks something like this (loosely mimicking Facebook's Post Graph API):
# ecto schema
schema "posts" do
field :message, :string
belongs_to :from, User, foreign_key: :from_user_id
belongs_to :to, User, foreign_key: :to_user_id
timestamps()
end
# graphql types
object :user do
field :id, :id
field :email, :string
field :first_name, :string
field :last_name, :string
field :wall, list_of(:post), resolve: assoc(:wall)
end
object :post do
field :id, :id
field :message, :string
field :from, :user, resolve: assoc(:from)
end
# graphql query
{
user (id: 1) {
wall {
message
from {
firstName
lastName
}
}
}
}
This results in two queries (one for posts, and one for users). Awesome!
from absinthe_ecto.
Cool!
from absinthe_ecto.
@bjunc hello, I'm trying something similar, how did you define your "users" schema?
from absinthe_ecto.
Related Issues (20)
- many_to_many associations HOT 1
- repo isn't on hex HOT 6
- dependency absinthe version HOT 1
- README suggestion
- Select only some schema fields HOT 2
- All association calls missing from MSSQL call HOT 1
- Using absinthe_ecto with absinthe_relay HOT 5
- New query fun addition breaks :through associations HOT 1
- Run tests on CI HOT 1
- Assoc helper, batch id and query fun HOT 4
- Fetch Single Record HOT 7
- Don't preload if only requesting the "id" field of a belongs_to association
- pagination macro in many_to_many ? HOT 4
- Mention deprecation at the top of the readme HOT 1
- can not upgrade to Dataloader HOT 1
- Please, support this package HOT 1
- Ecto.Schema resolution proposal HOT 29
- Providing a default order for an association HOT 8
- warning: this check/guard will always yield the same result HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from absinthe_ecto.