Skip to content

Filter nested many-to-one failing test #78

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

Closed
wants to merge 12 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@
package com.introproventures.graphql.jpa.query.example.starwars;

import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;

import com.introproventures.graphql.jpa.query.annotation.GraphQLDescription;

Expand All @@ -30,6 +33,8 @@
public class Droid extends Character {

@GraphQLDescription("Documents the primary purpose this droid serves")
String primaryFunction;
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "primary_function")
DroidFunction primaryFunction;

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package com.introproventures.graphql.jpa.query.example.starwars;

import com.introproventures.graphql.jpa.query.annotation.GraphQLDescription;
import lombok.Data;
import lombok.EqualsAndHashCode;

import javax.persistence.Entity;
import javax.persistence.Id;


@Entity(name = "droid_function")
@GraphQLDescription("Represents the functions a droid can have")
@Data
@EqualsAndHashCode()
public class DroidFunction {

@Id
@GraphQLDescription("Primary Key for the DroidFunction Class")
String id;

String function;



}
11 changes: 8 additions & 3 deletions graphql-jpa-query-example-merge/src/main/resources/starwars.sql
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,15 @@ insert into CodeList (id, type, code, description, sequence, active, parent_id)
(0, 'org.crygier.graphql.model.starwars.Gender', 'Male', 'Male', 1, true, null),
(1, 'org.crygier.graphql.model.starwars.Gender', 'Female', 'Female', 2, true, null);

-- Insert Droid Functions
insert into droid_function(id, function) values
( '1000', 'Protocol'),
( '1001', 'Astromech');

-- Insert Droids
insert into Character (id, name, primaryFunction, dtype) values
('2000', 'C-3PO', 'Protocol', 'Droid'),
('2001', 'R2-D2', 'Astromech', 'Droid');
insert into character (id, name, primary_function, dtype) values
('2000', 'C-3PO', '1000', 'Droid'),
('2001', 'R2-D2', '1001', 'Droid');

-- Insert Humans
insert into character (id, name, homePlanet, favorite_droid_id, dtype, gender_code_id) values
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package com.introproventures.graphql.jpa.query.example.starwars;

import com.introproventures.graphql.jpa.query.annotation.GraphQLDescription;
import lombok.Data;
import lombok.EqualsAndHashCode;

import javax.persistence.Entity;
import javax.persistence.Id;


@Entity(name = "droid_function")
@GraphQLDescription("Represents the functions a droid can have")
@Data
@EqualsAndHashCode()
public class DroidFunction {

@Id
@GraphQLDescription("Primary Key for the DroidFunction Class")
String id;

String function;



}
213 changes: 109 additions & 104 deletions graphql-jpa-query-example/src/main/resources/data.sql
Original file line number Diff line number Diff line change
@@ -1,104 +1,109 @@
-- Insert Code Lists
insert into code_list (id, type, code, description, sequence, active, parent_id) values
(0, 'org.crygier.graphql.model.starwars.Gender', 'Male', 'Male', 1, true, null),
(1, 'org.crygier.graphql.model.starwars.Gender', 'Female', 'Female', 2, true, null);

-- Insert Droids
insert into character (id, name, primary_function, dtype) values
('2000', 'C-3PO', 'Protocol', 'Droid'),
('2001', 'R2-D2', 'Astromech', 'Droid');

-- Insert Humans
insert into character (id, name, home_planet, favorite_droid_id, dtype, gender_code_id) values
('1000', 'Luke Skywalker', 'Tatooine', '2000', 'Human', 0),
('1001', 'Darth Vader', 'Tatooine', '2001', 'Human', 0),
('1002', 'Han Solo', NULL, NULL, 'Human', 0),
('1003', 'Leia Organa', 'Alderaan', NULL, 'Human', 1),
('1004', 'Wilhuff Tarkin', NULL, NULL, 'Human', 0);

-- Luke's friends
insert into character_friends (source_id, friend_id) values
('1000', '1002'),
('1000', '1003'),
('1000', '2000'),
('1000', '2001');

-- Luke Appears in
insert into character_appears_in (character_id, appears_in) values
('1000', 3),
('1000', 4),
('1000', 5),
('1000', 6);

-- Vader's friends
insert into character_friends (source_id, friend_id) values
('1001', '1004');

-- Vader Appears in
insert into character_appears_in (character_id, appears_in) values
('1001', 3),
('1001', 4),
('1001', 5);

-- Solo's friends
insert into character_friends (source_id, friend_id) values
('1002', '1000'),
('1002', '1003'),
('1002', '2001');

-- Solo Appears in
insert into character_appears_in (character_id, appears_in) values
('1002', 3),
('1002', 4),
('1002', 5),
('1002', 6);

-- Leia's friends
insert into character_friends (source_id, friend_id) values
('1003', '1000'),
('1003', '1002'),
('1003', '2000'),
('1003', '2001');

-- Leia Appears in
insert into character_appears_in (character_id, appears_in) values
('1003', 3),
('1003', 4),
('1003', 5),
('1003', 6);

-- Wilhuff's friends
insert into character_friends (source_id, friend_id) values
('1004', '1001');

-- Wilhuff Appears in
insert into character_appears_in (character_id, appears_in) values
('1004', 3);

-- C3PO's friends
insert into character_friends (source_id, friend_id) values
('2000', '1000'),
('2000', '1002'),
('2000', '1003'),
('2000', '2001');

-- C3PO Appears in
insert into character_appears_in (character_id, appears_in) values
('2000', 3),
('2000', 4),
('2000', 5),
('2000', 6);

-- R2's friends
insert into character_friends (source_id, friend_id) values
('2001', '1000'),
('2001', '1002'),
('2001', '1003');

-- R2 Appears in
insert into character_appears_in (character_id, appears_in) values
('2001', 3),
('2001', 4),
('2001', 5),
('2001', 6);

-- Insert Code Lists
insert into code_list (id, type, code, description, sequence, active, parent_id) values
(0, 'org.crygier.graphql.model.starwars.Gender', 'Male', 'Male', 1, true, null),
(1, 'org.crygier.graphql.model.starwars.Gender', 'Female', 'Female', 2, true, null);

-- Insert Droid Functions
insert into droid_function(id, function) values
( '1000', 'Protocol'),
( '1001', 'Astromech');

-- Insert Droids
insert into character (id, name, primary_function, dtype) values
('2000', 'C-3PO', '1000', 'Droid'),
('2001', 'R2-D2', '1001', 'Droid');

-- Insert Humans
insert into character (id, name, home_planet, favorite_droid_id, dtype, gender_code_id) values
('1000', 'Luke Skywalker', 'Tatooine', '2000', 'Human', 0),
('1001', 'Darth Vader', 'Tatooine', '2001', 'Human', 0),
('1002', 'Han Solo', NULL, NULL, 'Human', 0),
('1003', 'Leia Organa', 'Alderaan', NULL, 'Human', 1),
('1004', 'Wilhuff Tarkin', NULL, NULL, 'Human', 0);

-- Luke's friends
insert into character_friends (source_id, friend_id) values
('1000', '1002'),
('1000', '1003'),
('1000', '2000'),
('1000', '2001');

-- Luke Appears in
insert into character_appears_in (character_id, appears_in) values
('1000', 3),
('1000', 4),
('1000', 5),
('1000', 6);

-- Vader's friends
insert into character_friends (source_id, friend_id) values
('1001', '1004');

-- Vader Appears in
insert into character_appears_in (character_id, appears_in) values
('1001', 3),
('1001', 4),
('1001', 5);

-- Solo's friends
insert into character_friends (source_id, friend_id) values
('1002', '1000'),
('1002', '1003'),
('1002', '2001');

-- Solo Appears in
insert into character_appears_in (character_id, appears_in) values
('1002', 3),
('1002', 4),
('1002', 5),
('1002', 6);

-- Leia's friends
insert into character_friends (source_id, friend_id) values
('1003', '1000'),
('1003', '1002'),
('1003', '2000'),
('1003', '2001');

-- Leia Appears in
insert into character_appears_in (character_id, appears_in) values
('1003', 3),
('1003', 4),
('1003', 5),
('1003', 6);

-- Wilhuff's friends
insert into character_friends (source_id, friend_id) values
('1004', '1001');

-- Wilhuff Appears in
insert into character_appears_in (character_id, appears_in) values
('1004', 3);

-- C3PO's friends
insert into character_friends (source_id, friend_id) values
('2000', '1000'),
('2000', '1002'),
('2000', '1003'),
('2000', '2001');

-- C3PO Appears in
insert into character_appears_in (character_id, appears_in) values
('2000', 3),
('2000', 4),
('2000', 5),
('2000', 6);

-- R2's friends
insert into character_friends (source_id, friend_id) values
('2001', '1000'),
('2001', '1002'),
('2001', '1003');

-- R2 Appears in
insert into character_appears_in (character_id, appears_in) values
('2001', 3),
('2001', 4),
('2001', 5),
('2001', 6);

Loading