Skip to content
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

2 instances of DeleteInput type created #162

Closed
scallion5765 opened this issue Apr 15, 2021 · 1 comment · Fixed by #164
Closed

2 instances of DeleteInput type created #162

scallion5765 opened this issue Apr 15, 2021 · 1 comment · Fixed by #164
Labels
bug Something isn't working confirmed Confirmed bug

Comments

@scallion5765
Copy link

I believe I've found a bug in @neo4j/graphql. To reproduce it, see below.

Software

  • Operating system: Debian Linux 10
  • Node.js: version 14.16.1

Files

package.json

{
  "dependencies": {
    "@neo4j/graphql": "1.0.0-beta.2",
    "apollo-server": "2.23.0",
    "graphql": "15.5.0",
    "neo4j-driver": "4.2.3"
  }
}

server.js

'use strict';

const { Neo4jGraphQL } = require('@neo4j/graphql');
const neo4j = require('neo4j-driver');

const driver = neo4j.driver(
  'bolt://localhost:7687',
  neo4j.auth.basic('*****', '*****'),
);

const typeDefs = `
  type Tiger {
    x: Int
  }

  type TigerJawLevel2 {
    id: ID
    part1: TigerJawLevel2Part1 @relationship(type: "REL1", direction: OUT)
  }

  type TigerJawLevel2Part1 {
    id: ID
    tiger: Tiger @relationship(type: "REL2", direction: OUT)
  }
`;

new Neo4jGraphQL({
  driver,
  typeDefs,
});

Setup

  • Run the command npm install --no-save.

Steps to reproduce

  • Run the command node server.js.

Expected outcome

Nothing. That is, the command should exit almost immediately, with no output.

Actual outcome

The following error message:

/app/node_modules/graphql/validation/validate.js:107
    throw new Error(errors.map(function (error) {
    ^

Error: There can be only one type named "TigerJawLevel2Part1DeleteInput".
    at assertValidSDL (/app/node_modules/graphql/validation/validate.js:107:11)
    at Object.buildASTSchema (/app/node_modules/graphql/utilities/buildASTSchema.js:45:34)
    at buildSchemaFromTypeDefinitions (/app/node_modules/@graphql-tools/schema/index.cjs.js:203:26)
    at Object.makeExecutableSchema (/app/node_modules/@graphql-tools/schema/index.cjs.js:749:18)
    at Object.makeAugmentedSchema (/app/node_modules/@neo4j/graphql/dist/schema/make-augmented-schema.js:594:29)
    at new Neo4jGraphQL (/app/node_modules/@neo4j/graphql/dist/classes/Neo4jGraphQL.js:40:44)
    at Object.<anonymous> (/app/server.js:27:1)
    at Module._compile (internal/modules/cjs/loader.js:1063:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1092:10)
    at Module.load (internal/modules/cjs/loader.js:928:32)

Analysis

TigerJawLevel2Part1DeleteInput, the type that appears in the error message, is obviously a type created by @neo4j/graphql. (See the documentation here.) It appears that @neo4j/graphql creates two instances of this type. That behavior is surely a bug.

@scallion5765 scallion5765 added bug Something isn't working inbox labels Apr 15, 2021
@darrellwarde
Copy link
Contributor

I haven't investigated this yet, but I suspect that the two DeleteInput types are:

  • The input type for deleting TigerJawLevel2Part1 objects through the part1 field of the TigerJawLevel2 object - appended together you get "TigerJawLevel2" + "Part1" + "DeleteInput".
  • The input type for deleting TigerJawLevel2Part1 objects directly as a Mutation - appended together you get "TigerJawLevel2Part1" + "DeleteInput".

The resulting input type name is the same through both routes, which is obviously a problem! Realistically, I think the first input type should have been called TigerJawLevel2Part1DeleteFieldInput and this just slipped through the net.

@darrellwarde darrellwarde added the confirmed Confirmed bug label Apr 19, 2021
oskarhane added a commit to oskarhane/graphql that referenced this issue Jun 21, 2021
# Conflicts:
#	packages/graphql/src/schema/make-augmented-schema.ts
#	packages/graphql/src/translate/projection/elements/create-datetime-element.ts
#	packages/graphql/tests/tck/tck-test-files/schema/directives/exclude.md
#	packages/graphql/tests/tck/tck-test-files/schema/interfaces.md
#	packages/graphql/tests/tck/tck-test-files/schema/issues/neo4j#162.md
#	packages/graphql/tests/tck/tck-test-files/schema/relationship.md
#	packages/graphql/tests/tck/tck-test-files/schema/unions.md
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working confirmed Confirmed bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants