-
Notifications
You must be signed in to change notification settings - Fork 822
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
@searchable transforms and connections #763
Comments
Hey @helloniklas thanks for the question. This is not yet supported, but we would love to support use cases like this in the future. I think the best way to get movement on this would be to propose a design so that we can start getting feedback from the community. We will be investing more in enhancing auth support across the transform so any design should consider what authorization would look like. |
@mikeparisstuff this is a critical part for what we'd need. @helloniklas's scenario is fairly simple in that you can query posts and then get the votes through the standard GQL connection. However we are thinking of scenarios where we would need to search across joint datasets. We know in elastic there are different storage models, including structuring flat file nested properties or linking properties (meaning they'd live on the same shard - possible performance causes) - is there anywhere that could point to how we could create custom resolvers to get these to open up in a flat file? Using the above scenario meaning that the @searchable for Vote would contain both the Vote information + the post information. |
@mikeparisstuff, @kaustavghosh06 - Any movement on this? I've run into this a couple of times and I have to just stop and try to go around it a different way. It seems like supporting |
This gets a +1 from me. Maybe it's been addressed, but I've had difficulty finding documentation online. Given: type ObjectA @model @searchable {
id: ID!
objectB: ObjectB! @connection(name: "ObjectBToA")
}
type ObjectB @model @searchable {
id: ID!
objectAs: [ObjectA] @connection(name: "ObjectBToA")
} It would be handy to search for I've so far been injecting Elasticsearch queries directly by manually modifying the This is unsustainable, though. While I can define the Resolver as a VTL file under |
Any movement on this please? |
+1 I ran into this issue today and sadly the current solution is to copy the data over to one of the @model so you can query and update without breaking. |
+1 this is a big issue for us. |
Feedback we got from Amplify team is that they prioritize these issues by their engagement on Github so please upvote this issue and add your comments so this becomes a priority to them. For us not making @connection available to @searchable is a big limitation. |
+1 stumble on the same limitation, big deal. |
This would be a great feature, as it would save development time for us. |
Our team needs this! Would I be able to write a custom resolver to go around this limitation? |
I have also been needing this for a while on a project, so any progress towards it would be appreciated. In the meantime, is there any way to do this with a custom resolver? @alexboulay did you find a way around it? |
@KIWI-JP I ended up putting all the search terms in a list within the objects that I wanted to search. Its not the cleanest solution but it does work! |
Are there any updates on this? Any help would be appreciated! |
Hey y'all 👋 I wanted to follow-up on this one and show how this is now possible with GraphQL Transformer v2 and the new relational directives! Using the following schema we will be able to create a Post, create a Vote linked to the Post, then run a search query by post ID. type Post @model @searchable {
id: ID!
text: String
votes: [Vote] @hasMany
}
type Vote @model @searchable {
id: ID!
vote: Int!
post: Post!
} Then we can execute the following in order to ultimately search Votes by Post ID mutation CREATE_POST {
createPost(input: {text: "my first post"}) {
id
}
}
mutation CREATE_VOTE {
createVote(input: {vote: 10, postVotesId: "a7173361-d420-44fd-abb9-88b26f7a506b"}) {
id
}
}
query SEARCH_BY_ID {
searchVotes(filter: {postVotesId: {eq: "a7173361-d420-44fd-abb9-88b26f7a506b"}}) {
items {
id
postVotesId
vote
}
}
} Where the search query will return: {
"data": {
"searchVotes": {
"items": [
{
"id": "34caeece-2530-452c-8965-0f3d097b545c",
"postVotesId": "a7173361-d420-44fd-abb9-88b26f7a506b",
"vote": 10
}
]
}
}
} Closing issue 🙂 if you feel this does not quite cover your use case please reply back to this thread and we can re-open to investigate further! |
How to search votes by text in related posts? For example how to get votes, where related post contains word "test" in field |
I am using GraphQL Transformer v2. If you need to search votes by text in related posts in the schema above, you should re-evaluate your access patterns. To search votes by text in related posts, you can search posts by text first and then just tell AppSync to append corresponding posts:
That query above would give you something like this: ![]() If response is containing non-null nextToken somewhere, usually it means there are more results to be fetched. Here you can see how to pass nextToken to the outer search results ( ![]() But if those search results looks like this (indicating that not the all of nested votes have not been fetched): ![]() You would either need to bump limit for sub-selection or you would need to pass nextToken to inner searchPostsThatEndsWithPost.items.votes.nextToken like this:
The problem with that is that nextToken is applied to every subselection and you would get also this error:
![]() so in that case (fetching nested items) you would need to narrow down the search query to get only one post and the query would look like:
It's not intuitive to use this approach, but it seems to be possible. Another approach (that I would prefer) would be
![]() |
I have two types: type Post
@model
@searchable {
hash: String! @primaryKey
user: User! @hasOne
} type User
@model
@searchable {
sub: String! @primaryKey
username: String!
} I would like to search for let searchPostsResult = await API.graphql({
authMode: GRAPHQL_AUTH_MODE.AWS_IAM,
query: searchPosts,
variables: {
filter: {
user: {
username: {
matchPhrasePrefix "asdf",
},
},
},
},
}); However, this is impossible. Or is it? Is there a way to achieve something like this? |
Is this still not possible? |
Is there a way to get the @searchable to also work with @connection. Say I have these models.
The generated searchVotes query would then only be able to filter on id and vote. But say I want to get all the votes for a certain postId.
Likewise the ListVotes query doesn't either provide a filter on the post connection.
So how would I in this case go about to get all the Votes on a certain post?
The text was updated successfully, but these errors were encountered: