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

Proposal allow aliasing fields #141

Closed
Andy2003 opened this issue Mar 5, 2021 · 3 comments · Fixed by #463
Closed

Proposal allow aliasing fields #141

Andy2003 opened this issue Mar 5, 2021 · 3 comments · Fixed by #463
Labels
feature request New feature or request

Comments

@Andy2003
Copy link
Contributor

Andy2003 commented Mar 5, 2021

Provide an @property directive to change the name used for the database mappings.

With schema:

type Person {
  id : ID! @property(name:"an-id")
  name: String @property(name:" a name ")
}

And query:

{ person(id:"32",name:"Jane") { name }}

Should generate something like:

MATCH (person:Person)
WHERE (person.`an-id` = $personId
	AND person.` a name ` = $personName)
RETURN person {
	name: person.` a name `
} AS person

see also: https://github.com/neo4j-graphql/neo4j-graphql-java/blob/master/core/src/test/resources/property-tests.adoc

@darrellwarde
Copy link
Contributor

This is going to be more valuable for users of this library with an existing dataset, but want to map the backend property to a different field name on the frontend. These users aren't our current target audience, but I will leave this open as it probably is a feature we should add in the future.

@Andy2003
Copy link
Contributor Author

Andy2003 commented Mar 5, 2021

@darrellwarde You may have a look at lib_directives.graphql. This is how we define the directives in java. This file (and neo4j_types.graphql) are then loaded into the user provided schema:

https://github.com/neo4j-graphql/neo4j-graphql-java/blob/master/core/src/main/kotlin/org/neo4j/graphql/SchemaBuilder.kt#L225-L237

This is especially helpful since the graphql framework will take care about validating the schema and applying default values.

@danstarns
Copy link
Contributor

danstarns commented Mar 5, 2021

@Andy2003 in the current implementation we don't type the directives, as untyped means we can offer greater flexibility IMO*, this is up for discussion internally. If you look at the output schema; no sign of directives. The directive metadata is stored on the Neo4jGraphQL class instead. I do think we should pick up on enum values over strings, in certain places, and so something defo worth looking into.

PS - I think this comment is in the wrong place

@darrellwarde darrellwarde transferred this issue from another repository Apr 8, 2021
@darrellwarde darrellwarde added inbox feature request New feature or request labels May 7, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature request New feature or request
Projects
None yet
3 participants