-
Notifications
You must be signed in to change notification settings - Fork 115
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
GraphQL projects
output field
#1547
Open
plyhun
wants to merge
3
commits into
hotfix-1.10.x
Choose a base branch
from
hotfix-1.10.x-sup-15971
base: hotfix-1.10.x
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
87 changes: 80 additions & 7 deletions
87
tests/tests-core/src/main/resources/graphql/microschema-projects-query
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,93 @@ | ||
{ | ||
microschema(name:"vcard") { | ||
vcard: microschema(name:"vcard") { | ||
projects { | ||
# [$.data.microschema.projects.elements.size()=1] | ||
# [$.data.vcard.projects.elements.size()=1] | ||
elements { | ||
# [$.data.microschema.projects.elements[0].name=dummy] | ||
# [$.data.vcard.projects.elements[0].name=dummy] | ||
name | ||
# [$.data.microschema.projects.elements[0].uuid=<is-uuid>] | ||
# [$.data.vcard.projects.elements[0].uuid=<is-uuid>] | ||
uuid | ||
# [$.data.microschema.projects.elements[0].etag=<is-not-null>] | ||
# [$.data.vcard.projects.elements[0].etag=<is-not-null>] | ||
etag | ||
# [$.data.microschema.projects.elements[0].created=<is-not-null>] | ||
# [$.data.vcard.projects.elements[0].created=<is-not-null>] | ||
created | ||
# [$.data.microschema.projects.elements[0].edited=<is-not-null>] | ||
# [$.data.vcard.projects.elements[0].edited=<is-not-null>] | ||
edited | ||
} | ||
} | ||
} | ||
all: microschemas { | ||
elements { | ||
projects { | ||
# [$.data.all.elements[0].projects.elements.size()=1] | ||
elements { | ||
# [$.data.all.elements[0].projects.elements[0].name=dummy] | ||
name | ||
# [$.data.all.elements[0].projects.elements[0].uuid=<is-uuid>] | ||
uuid | ||
# [$.data.all.elements[0].projects.elements[0].etag=<is-not-null>] | ||
etag | ||
# [$.data.all.elements[0].projects.elements[0].created=<is-not-null>] | ||
created | ||
# [$.data.all.elements[0].projects.elements[0].edited=<is-not-null>] | ||
edited | ||
} | ||
} | ||
} | ||
} | ||
vcard_bogus: microschema(name:"vcard") { | ||
projects(filter: {name: {equals: "bogus"}}) { | ||
# [$.data.vcard_bogus.projects.elements.size()=0] | ||
elements { | ||
uuid | ||
} | ||
} | ||
} | ||
all_bogus: microschemas { | ||
elements { | ||
projects(filter: {name: {equals: "bogus"}}) { | ||
# [$.data.all_bogus.elements[0].projects.elements.size()=0] | ||
elements { | ||
uuid | ||
} | ||
} | ||
} | ||
} | ||
vcard_dummy: microschema(name:"vcard") { | ||
projects(filter: {name: {equals: "dummy"}}) { | ||
# [$.data.vcard_dummy.projects.elements.size()=1] | ||
elements { | ||
# [$.data.vcard_dummy.projects.elements[0].name=dummy] | ||
name | ||
# [$.data.vcard_dummy.projects.elements[0].uuid=<is-uuid>] | ||
uuid | ||
# [$.data.vcard_dummy.projects.elements[0].etag=<is-not-null>] | ||
etag | ||
# [$.data.vcard_dummy.projects.elements[0].created=<is-not-null>] | ||
created | ||
# [$.data.vcard_dummy.projects.elements[0].edited=<is-not-null>] | ||
edited | ||
} | ||
} | ||
} | ||
all_dummy: microschemas { | ||
elements { | ||
projects(filter: {name: {equals: "dummy"}}) { | ||
# [$.data.all_dummy.elements[0].projects.elements.size()=1] | ||
elements { | ||
# [$.data.all_dummy.elements[0].projects.elements[0].name=dummy] | ||
name | ||
# [$.data.all_dummy.elements[0].projects.elements[0].uuid=<is-uuid>] | ||
uuid | ||
# [$.data.all_dummy.elements[0].projects.elements[0].etag=<is-not-null>] | ||
etag | ||
# [$.data.all_dummy.elements[0].projects.elements[0].created=<is-not-null>] | ||
created | ||
# [$.data.all_dummy.elements[0].projects.elements[0].edited=<is-not-null>] | ||
edited | ||
} | ||
} | ||
} | ||
} | ||
} | ||
# [$.errors=<is-undefined>] |
87 changes: 80 additions & 7 deletions
87
tests/tests-core/src/main/resources/graphql/schema-projects-query
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,93 @@ | ||
{ | ||
schema(name:"content") { | ||
content: schema(name:"content") { | ||
projects { | ||
# [$.data.schema.projects.elements.size()=1] | ||
# [$.data.content.projects.elements.size()=1] | ||
elements { | ||
# [$.data.schema.projects.elements[0].name=dummy] | ||
# [$.data.content.projects.elements[0].name=dummy] | ||
name | ||
# [$.data.schema.projects.elements[0].uuid=<is-uuid>] | ||
# [$.data.content.projects.elements[0].uuid=<is-uuid>] | ||
uuid | ||
# [$.data.schema.projects.elements[0].uuid=<is-not-null>] | ||
# [$.data.content.projects.elements[0].uuid=<is-not-null>] | ||
etag | ||
# [$.data.schema.projects.elements[0].uuid=<is-not-null>] | ||
# [$.data.content.projects.elements[0].uuid=<is-not-null>] | ||
created | ||
# [$.data.schema.projects.elements[0].uuid=<is-not-null>] | ||
# [$.data.content.projects.elements[0].uuid=<is-not-null>] | ||
edited | ||
} | ||
} | ||
} | ||
all: schemas { | ||
elements { | ||
projects { | ||
# [$.data.all.elements[0].projects.elements.size()=1] | ||
elements { | ||
# [$.data.all.elements[0].projects.elements[0].name=dummy] | ||
name | ||
# [$.data.all.elements[0].projects.elements[0].uuid=<is-uuid>] | ||
uuid | ||
# [$.data.all.elements[0].projects.elements[0].uuid=<is-not-null>] | ||
etag | ||
# [$.data.all.elements[0].projects.elements[0].uuid=<is-not-null>] | ||
created | ||
# [$.data.all.elements[0].projects.elements[0].uuid=<is-not-null>] | ||
edited | ||
} | ||
} | ||
} | ||
} | ||
content_bogus: schema(name:"content") { | ||
projects (filter: {name: {equals: "bogus"}}) { | ||
# [$.data.content_bogus.projects.elements.size()=0] | ||
elements { | ||
name | ||
} | ||
} | ||
} | ||
all_bogus: schemas { | ||
elements { | ||
projects (filter: {name: {equals: "bogus"}}) { | ||
# [$.data.all_bogus.elements[0].projects.elements.size()=0] | ||
elements { | ||
name | ||
} | ||
} | ||
} | ||
} | ||
content_dummy: schema(name:"content") { | ||
projects (filter: {name: {equals: "dummy"}}) { | ||
# [$.data.content_dummy.projects.elements.size()=1] | ||
elements { | ||
# [$.data.content_dummy.projects.elements[0].name=dummy] | ||
name | ||
# [$.data.content_dummy.projects.elements[0].uuid=<is-uuid>] | ||
uuid | ||
# [$.data.content_dummy.projects.elements[0].uuid=<is-not-null>] | ||
etag | ||
# [$.data.content_dummy.projects.elements[0].uuid=<is-not-null>] | ||
created | ||
# [$.data.content_dummy.projects.elements[0].uuid=<is-not-null>] | ||
edited | ||
} | ||
} | ||
} | ||
all_dummy: schemas { | ||
elements { | ||
projects (filter: {name: {equals: "dummy"}}) { | ||
# [$.data.all_dummy.elements[0].projects.elements.size()=1] | ||
elements { | ||
# [$.data.all_dummy.elements[0].projects.elements[0].name=dummy] | ||
name | ||
# [$.data.all_dummy.elements[0].projects.elements[0].uuid=<is-uuid>] | ||
uuid | ||
# [$.data.all_dummy.elements[0].projects.elements[0].uuid=<is-not-null>] | ||
etag | ||
# [$.data.all_dummy.elements[0].projects.elements[0].uuid=<is-not-null>] | ||
created | ||
# [$.data.all_dummy.elements[0].projects.elements[0].uuid=<is-not-null>] | ||
edited | ||
} | ||
} | ||
} | ||
} | ||
} | ||
# [$.errors=<is-undefined>] |
58 changes: 58 additions & 0 deletions
58
verticles/graphql/src/main/java/com/gentics/mesh/graphql/filter/ProjectFilter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
package com.gentics.mesh.graphql.filter; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
import com.gentics.graphqlfilter.filter.FilterField; | ||
import com.gentics.graphqlfilter.filter.MappedFilter; | ||
import com.gentics.graphqlfilter.filter.StartMainFilter; | ||
import com.gentics.graphqlfilter.filter.StringFilter; | ||
import com.gentics.mesh.core.data.project.HibProject; | ||
|
||
import graphql.schema.GraphQLInputType; | ||
import graphql.schema.GraphQLTypeReference; | ||
|
||
/** | ||
* Start project GraphQL filter | ||
*/ | ||
public class ProjectFilter extends StartMainFilter<HibProject> { | ||
|
||
private static final String NAME = "ProjectFilter"; | ||
|
||
private static ProjectFilter instance; | ||
public static synchronized ProjectFilter filter() { | ||
if (instance == null) { | ||
instance = new ProjectFilter(); | ||
} | ||
return instance; | ||
} | ||
|
||
private final boolean byRef; | ||
|
||
private ProjectFilter() { | ||
this(false); | ||
} | ||
|
||
private ProjectFilter(boolean byRef) { | ||
super(NAME, "Filters projects"); | ||
this.byRef = byRef; | ||
} | ||
|
||
@Override | ||
public GraphQLInputType getType() { | ||
if (byRef) { | ||
return GraphQLTypeReference.typeRef(NAME); | ||
} else { | ||
return super.getType(); | ||
} | ||
} | ||
|
||
@Override | ||
protected List<FilterField<HibProject, ?>> getFilters() { | ||
List<FilterField<HibProject, ?>> filters = new ArrayList<>(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Possible filtering fields for the project: name, UUID, user tracking. |
||
filters.add(CommonFields.hibUuidFilter()); | ||
filters.addAll(CommonFields.hibUserTrackingFilter()); | ||
filters.add(new MappedFilter<>("name", "Filters by name", StringFilter.filter(), HibProject::getName)); | ||
return filters; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the test AW MP database there was a case when a ODB edge existed, but lead to nothing.