neo4j / graphql

A GraphQL to Cypher query execution layer for Neo4j and JavaScript GraphQL implementations.
https://neo4j.com/docs/graphql-manual/current/
Apache License 2.0
497 stars 147 forks source link

@unique ignores BigInt fields #5461

Closed mobsean closed 1 month ago

mobsean commented 1 month ago

Describe the bug Using @unique directive works for Int typed fields, but not for BigInt fields.

Type definitions

const typeDefs = `#graphql
    type Test {
        id: BigInt! @unique
    }
`;

To Reproduce Steps to reproduce the behavior:

  1. Run a server with the following code...
import { ApolloServer } from '@apollo/server';
import { startStandaloneServer } from '@apollo/server/standalone';
import { Neo4jGraphQL } from "@neo4j/graphql";
import neo4j from "neo4j-driver";

const typeDefs = `#graphql
    type Test {
        id: BigInt! @unique
    }
`;

const uri = "bolt://localhost:4000"
const user = "user"
const pw = "super-secret"

const driver = neo4j.driver(
    uri,
    neo4j.auth.basic(user, pw)
);

const neoSchema = new Neo4jGraphQL({ typeDefs, driver });

async function assertIndexesAndConstaints () {
    try {
        neoSchema.getSchema()
        await neoSchema.assertIndexesAndConstraints({
        options: { create: true },
        })
        return true
    } catch (e) {
        console.error(e)
        return false
    }
}
assertIndexesAndConstaints()

const server = new ApolloServer({
    schema: await neoSchema.getSchema(),
});

const { url } = await startStandaloneServer(server, {
    context: async ({ req }) => ({ req }),
    listen: { port: 4001 },
});

console.log(`🚀 Server ready at ${url}`);
  1. Server starts, but no unique constraint is created
  2. change line: id: BigInt! @unique to id: Int! @unique and restart server
  3. unique constraint gets created. @neo4j/graphql:execution Created 1 new constraint +58ms

Expected behavior

@unique should create constraints for every field type. espacially the supported types from docs

System (please complete the following information):

Additional context

this used to work in Version 3.x.x of this lib as expected.

neo4j-team-graphql commented 1 month ago

Many thanks for raising this bug report @mobsean. :bug: 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! :pray:

neo4j-team-graphql commented 1 month ago

We've been able to confirm this bug using the steps to reproduce that you provided - many thanks @mobsean! :pray: We will now prioritise the bug and address it appropriately.