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

Unable to apply constraints to a new Apollo server project #52

Closed
gpaluk opened this issue Dec 30, 2020 · 6 comments
Closed

Unable to apply constraints to a new Apollo server project #52

gpaluk opened this issue Dec 30, 2020 · 6 comments
Labels
question Further information is requested

Comments

@gpaluk
Copy link

gpaluk commented Dec 30, 2020

I am getting back no errors when I apply constraints to my new Apollo server project. I have created a minimal project to illustrate the point at:

https://github.com/gpaluk/apollo-graphql-mfp

When using the following GraphQL query in the playground, the entity gets created which is undesired:

mutation {
  CreateUser(userRole:"admin", username:"a", email:"a")
  {
    userRole
    username
    email
  }
}
@confuser confuser added the enhancement New feature or request label Dec 31, 2020
@confuser
Copy link
Owner

It looks like you're using neo4j-graphql-js instead of graphql-tools makeExecutableSchema function. I'm not familiar with it nor has this module been tested against it. Would suggest opening an issue with the author, happy to accept a PR to add compatibility.

@gpaluk
Copy link
Author

gpaluk commented Jan 9, 2021

During ongoing discussions over at: neo4j-graphql/neo4j-graphql-js#562 - I have been testing around this library and have a question about the working ideas of this library. Entities seem to be added into the database regardless of whether or not they are valid?!.. Then only if one is to return the field in the GraphQL statement does the check occur and return an error response (Which aught to compose a response that contains all errors)?! I'm quite confused to implementation concepts as this doesn't at all correlate to the way that validation is usually implemented (To guard database entries against invalid data). Is there a setting that I'm missing that makes this work as I think most people would assume? Many thanks

@gpaluk
Copy link
Author

gpaluk commented Jan 9, 2021

I have tested just the @unique annotation from neo4j-graphql-js and that guards against the insertion of entities into the database as expected.

@confuser
Copy link
Owner

confuser commented Jan 9, 2021

The issue you're describing is still likely caused by neo4j-graphql-js. I've checked your example repo, and within the schema I can't see any inputs being defined, nor can I see where your mutation queries are being defined either?

type Mutation {
  createBook(input: BookInput): Book
}
input BookInput {
  title: String! @constraint(minLength: 5, format: "email")
}

@gpaluk
Copy link
Author

gpaluk commented Jan 10, 2021

Hi @confuser - Actually, everything is autogenerated by makeAugmentedSchema. This should be clear if you build and head to the playground. All of the schema is described in the relevant tab as usual.

@confuser confuser added question Further information is requested and removed enhancement New feature or request labels Jan 25, 2021
@confuser
Copy link
Owner

confuser commented Mar 9, 2021

@gpaluk closing as it appears to be neo4j specific based on neo4j-graphql/neo4j-graphql-js#562

@confuser confuser closed this as completed Mar 9, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants