-
Notifications
You must be signed in to change notification settings - Fork 147
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
Model.find({where: {id}}) returns wrong output. #5078
Comments
Many thanks for raising this bug report @gethassaan. 🐛 We will now attempt to reproduce the bug based on the steps you have provided. Please ensure that you've provided the necessary information for a minimal reproduction, including but not limited to:
If you have a support agreement with Neo4j, please link this GitHub issue to a new or existing Zendesk ticket. Thanks again! 🙏 |
Hi @gethassaan I tried to reproduce this, but I can successfully request specific users via their IDs, without any issue. Some thoughts:
|
Hey @mjfwebb, I created the user via Graphql and the ID's were auto generated and regarding the cache i'm sure it's not cache since I also tried this with a new (fresh) clone. And as I am trying a simple query as mentioned above, I am out of clues to why this might be happening. 🥲 Can you also share how did you fetch the users? Any process or steps that you followed? |
Sure, here's what I did: import { ApolloServer } from "@apollo/server";
import { startStandaloneServer } from "@apollo/server/standalone";
import { Neo4jGraphQL } from "@neo4j/graphql";
import { OGM } from "@neo4j/graphql-ogm";
import neo4j from "neo4j-driver";
const driver = neo4j.driver(
"bolt://localhost:7687",
neo4j.auth.basic("username", "password")
);
const typeDefs = `#graphql
type User {
id: ID! @id
firstName: String!
lastName: String!
email: String! @unique
}
`;
const ogm = new OGM({ typeDefs, driver });
const User = ogm.model("User");
const resolvers = {};
const neoSchema = new Neo4jGraphQL({
typeDefs,
driver,
resolvers,
});
async function main() {
const schema = await neoSchema.getSchema();
await ogm.init();
const server = new ApolloServer({
schema,
});
const { url } = await startStandaloneServer(server, {
context: async ({ req }) => ({ req }),
});
console.log(`🚀 Server ready at ${url}`);
const [record] = await User.find({
where: { id: "your-id-here" },
});
console.log(record);
}
main(); Where you replace mutation Mutation {
createUsers(
input: [{ email: "test@example.com", firstName: "First", lastName: "Last" }]
) {
users {
id
}
}
} |
Thank you @mjfwebb your solution does work, I am not sure why would the bug be coming up. 🤔 |
@gethassaan I'll close the issue then, since we confirmed it's not on our side. |
Describe the bug
I have an application using Nestjs, Graphql and Neo4j. It has a user model and I have used
@neo4j/graphql-ogm
package and it'sgenerate
function to generate OGM object. When I try to get the user byid
usingfind
function it returns wrong result.Type definitions
To Reproduce
Steps to reproduce the behavior:
id
(for me it's returning the first user everytime instead of returning the user with matchingid
)Expected behavior
The function should return the result with the passed
id
.Screenshots
![Screenshot 2024-05-05 at 2 21 32 PM](https://private-user-images.githubusercontent.com/26020244/328017002-bd9af60d-5495-4f92-ac7c-32c1ff325049.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MTk2OTE2MDUsIm5iZiI6MTcxOTY5MTMwNSwicGF0aCI6Ii8yNjAyMDI0NC8zMjgwMTcwMDItYmQ5YWY2MGQtNTQ5NS00ZjkyLWFjN2MtMzJjMWZmMzI1MDQ5LnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA2MjklMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwNjI5VDIwMDE0NVomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPWE5OTI4ZDU3MmFhNmQ2OWMyYjQ0MWM4MGJlNWU0NDAxY2E4MjViNDBhM2ViN2IyYTdkZGEyNzU0ZjczN2RiNDQmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.1xw_9wi4_wDn6l13fcPClPGxpJ2uZPJ_KuqnThiSDwM)
If applicable, add screenshots to help explain your problem.
System (please complete the following information):
The text was updated successfully, but these errors were encountered: