Skip to content

Commit 59514b6

Browse files
authored
Support inline fragments (rubengrill#4)
1 parent 396d166 commit 59514b6

File tree

6 files changed

+583
-185
lines changed

6 files changed

+583
-185
lines changed

examples/cra-ts/src/apolloMock.js

Lines changed: 30 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,84 +10,104 @@ operations.authors = {};
1010
operations.authors.variables = (values = {}, options = {}) => {
1111
const __typename = '';
1212
values = (({ }) => ({ }))(values);
13-
return {
13+
values.__typename = __typename;
14+
let result = {
1415

1516
};
17+
return result;
1618
}
1719
operations.authors.data = (values = {}, options = {}) => {
1820
const __typename = '';
1921
values = (({ authors = null }) => ({ authors }))(values);
20-
return {
22+
values.__typename = __typename;
23+
let result = {
2124
authors: (values.authors || []).map(item => ((values = {}, options = {}) => {
2225
const __typename = 'Author';
2326
values = (({ id = null, name = null, description = null, books = null }) => ({ id, name, description, books }))(values);
24-
return {
27+
values.__typename = __typename;
28+
let result = {
2529
id: (values.id === null || values.id === undefined) ? [__typename, 'id'].filter(v => v).join('-') : values.id,
2630
name: (values.name === null || values.name === undefined) ? [__typename, 'name'].filter(v => v).join('-') : values.name,
2731
description: values.description,
2832
books: (values.books || []).map(item => ((values = {}, options = {}) => {
2933
const __typename = 'Book';
3034
values = (({ id = null, title = null }) => ({ id, title }))(values);
31-
return {
35+
values.__typename = __typename;
36+
let result = {
3237
id: (values.id === null || values.id === undefined) ? [__typename, 'id'].filter(v => v).join('-') : values.id,
3338
title: (values.title === null || values.title === undefined) ? [__typename, 'title'].filter(v => v).join('-') : values.title,
3439
...(options.addTypename ? { __typename } : {})
3540
};
41+
return result;
3642
})(item, options)),
3743
...(options.addTypename ? { __typename } : {})
3844
};
45+
return result;
3946
})(item, options))
4047
};
48+
return result;
4149
}
4250

4351
operations.createAuthor = {};
4452
operations.createAuthor.variables = (values = {}, options = {}) => {
4553
const __typename = '';
4654
values = (({ input = undefined }) => ({ input }))(values);
47-
return {
55+
values.__typename = __typename;
56+
let result = {
4857
input: (AuthorInput)(values.input || undefined, options)
4958
};
59+
return result;
5060
}
5161
operations.createAuthor.data = (values = {}, options = {}) => {
5262
const __typename = '';
5363
values = (({ createAuthor = null }) => ({ createAuthor }))(values);
54-
return {
64+
values.__typename = __typename;
65+
let result = {
5566
createAuthor: ((values = {}, options = {}) => {
5667
const __typename = 'Author';
5768
values = (({ id = null, name = null, description = null, books = null }) => ({ id, name, description, books }))(values);
58-
return {
69+
values.__typename = __typename;
70+
let result = {
5971
id: (values.id === null || values.id === undefined) ? [__typename, 'id'].filter(v => v).join('-') : values.id,
6072
name: (values.name === null || values.name === undefined) ? [__typename, 'name'].filter(v => v).join('-') : values.name,
6173
description: values.description,
6274
books: (values.books || []).map(item => ((values = {}, options = {}) => {
6375
const __typename = 'Book';
6476
values = (({ id = null, title = null }) => ({ id, title }))(values);
65-
return {
77+
values.__typename = __typename;
78+
let result = {
6679
id: (values.id === null || values.id === undefined) ? [__typename, 'id'].filter(v => v).join('-') : values.id,
6780
title: (values.title === null || values.title === undefined) ? [__typename, 'title'].filter(v => v).join('-') : values.title,
6881
...(options.addTypename ? { __typename } : {})
6982
};
83+
return result;
7084
})(item, options)),
7185
...(options.addTypename ? { __typename } : {})
7286
};
87+
return result;
7388
})(values.createAuthor || undefined, options)
7489
};
90+
return result;
7591
}
7692

7793
const BookInput = (values = {}, options = {}) => {
7894
const __typename = 'BookInput';
7995
values = (({ title = undefined }) => ({ title }))(values);
80-
return {
96+
values.__typename = __typename;
97+
let result = {
8198
title: (values.title === null || values.title === undefined) ? [__typename, 'title'].filter(v => v).join('-') : values.title
8299
};
100+
return result;
83101
}
84102

85103
const AuthorInput = (values = {}, options = {}) => {
86104
const __typename = 'AuthorInput';
87105
values = (({ name = undefined, description = undefined, books = undefined }) => ({ name, description, books }))(values);
88-
return {
106+
values.__typename = __typename;
107+
let result = {
89108
name: (values.name === null || values.name === undefined) ? [__typename, 'name'].filter(v => v).join('-') : values.name,
90109
description: values.description,
91110
books: (values.books || []).map(item => (BookInput)(item, options))
92111
};
112+
return result;
93113
}

examples/cra/src/apolloMock.js

Lines changed: 30 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,84 +10,104 @@ operations.authors = {};
1010
operations.authors.variables = (values = {}, options = {}) => {
1111
const __typename = '';
1212
values = (({ }) => ({ }))(values);
13-
return {
13+
values.__typename = __typename;
14+
let result = {
1415

1516
};
17+
return result;
1618
}
1719
operations.authors.data = (values = {}, options = {}) => {
1820
const __typename = '';
1921
values = (({ authors = null }) => ({ authors }))(values);
20-
return {
22+
values.__typename = __typename;
23+
let result = {
2124
authors: (values.authors || []).map(item => ((values = {}, options = {}) => {
2225
const __typename = 'Author';
2326
values = (({ id = null, name = null, description = null, books = null }) => ({ id, name, description, books }))(values);
24-
return {
27+
values.__typename = __typename;
28+
let result = {
2529
id: (values.id === null || values.id === undefined) ? [__typename, 'id'].filter(v => v).join('-') : values.id,
2630
name: (values.name === null || values.name === undefined) ? [__typename, 'name'].filter(v => v).join('-') : values.name,
2731
description: values.description,
2832
books: (values.books || []).map(item => ((values = {}, options = {}) => {
2933
const __typename = 'Book';
3034
values = (({ id = null, title = null }) => ({ id, title }))(values);
31-
return {
35+
values.__typename = __typename;
36+
let result = {
3237
id: (values.id === null || values.id === undefined) ? [__typename, 'id'].filter(v => v).join('-') : values.id,
3338
title: (values.title === null || values.title === undefined) ? [__typename, 'title'].filter(v => v).join('-') : values.title,
3439
...(options.addTypename ? { __typename } : {})
3540
};
41+
return result;
3642
})(item, options)),
3743
...(options.addTypename ? { __typename } : {})
3844
};
45+
return result;
3946
})(item, options))
4047
};
48+
return result;
4149
}
4250

4351
operations.createAuthor = {};
4452
operations.createAuthor.variables = (values = {}, options = {}) => {
4553
const __typename = '';
4654
values = (({ input = undefined }) => ({ input }))(values);
47-
return {
55+
values.__typename = __typename;
56+
let result = {
4857
input: (AuthorInput)(values.input || undefined, options)
4958
};
59+
return result;
5060
}
5161
operations.createAuthor.data = (values = {}, options = {}) => {
5262
const __typename = '';
5363
values = (({ createAuthor = null }) => ({ createAuthor }))(values);
54-
return {
64+
values.__typename = __typename;
65+
let result = {
5566
createAuthor: ((values = {}, options = {}) => {
5667
const __typename = 'Author';
5768
values = (({ id = null, name = null, description = null, books = null }) => ({ id, name, description, books }))(values);
58-
return {
69+
values.__typename = __typename;
70+
let result = {
5971
id: (values.id === null || values.id === undefined) ? [__typename, 'id'].filter(v => v).join('-') : values.id,
6072
name: (values.name === null || values.name === undefined) ? [__typename, 'name'].filter(v => v).join('-') : values.name,
6173
description: values.description,
6274
books: (values.books || []).map(item => ((values = {}, options = {}) => {
6375
const __typename = 'Book';
6476
values = (({ id = null, title = null }) => ({ id, title }))(values);
65-
return {
77+
values.__typename = __typename;
78+
let result = {
6679
id: (values.id === null || values.id === undefined) ? [__typename, 'id'].filter(v => v).join('-') : values.id,
6780
title: (values.title === null || values.title === undefined) ? [__typename, 'title'].filter(v => v).join('-') : values.title,
6881
...(options.addTypename ? { __typename } : {})
6982
};
83+
return result;
7084
})(item, options)),
7185
...(options.addTypename ? { __typename } : {})
7286
};
87+
return result;
7388
})(values.createAuthor || undefined, options)
7489
};
90+
return result;
7591
}
7692

7793
const BookInput = (values = {}, options = {}) => {
7894
const __typename = 'BookInput';
7995
values = (({ title = undefined }) => ({ title }))(values);
80-
return {
96+
values.__typename = __typename;
97+
let result = {
8198
title: (values.title === null || values.title === undefined) ? [__typename, 'title'].filter(v => v).join('-') : values.title
8299
};
100+
return result;
83101
}
84102

85103
const AuthorInput = (values = {}, options = {}) => {
86104
const __typename = 'AuthorInput';
87105
values = (({ name = undefined, description = undefined, books = undefined }) => ({ name, description, books }))(values);
88-
return {
106+
values.__typename = __typename;
107+
let result = {
89108
name: (values.name === null || values.name === undefined) ? [__typename, 'name'].filter(v => v).join('-') : values.name,
90109
description: values.description,
91110
books: (values.books || []).map(item => (BookInput)(item, options))
92111
};
112+
return result;
93113
}

examples/docs/src/apolloMock.js

Lines changed: 30 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,84 +8,104 @@ operations.authors = {};
88
operations.authors.variables = (values = {}, options = {}) => {
99
const __typename = '';
1010
values = (({ }) => ({ }))(values);
11-
return {
11+
values.__typename = __typename;
12+
let result = {
1213

1314
};
15+
return result;
1416
}
1517
operations.authors.data = (values = {}, options = {}) => {
1618
const __typename = '';
1719
values = (({ authors = null }) => ({ authors }))(values);
18-
return {
20+
values.__typename = __typename;
21+
let result = {
1922
authors: (values.authors || []).map(item => ((values = {}, options = {}) => {
2023
const __typename = 'Author';
2124
values = (({ id = null, name = null, description = null, books = null }) => ({ id, name, description, books }))(values);
22-
return {
25+
values.__typename = __typename;
26+
let result = {
2327
id: (values.id === null || values.id === undefined) ? [__typename, 'id'].filter(v => v).join('-') : values.id,
2428
name: (values.name === null || values.name === undefined) ? [__typename, 'name'].filter(v => v).join('-') : values.name,
2529
description: values.description,
2630
books: (values.books || []).map(item => ((values = {}, options = {}) => {
2731
const __typename = 'Book';
2832
values = (({ id = null, title = null }) => ({ id, title }))(values);
29-
return {
33+
values.__typename = __typename;
34+
let result = {
3035
id: (values.id === null || values.id === undefined) ? [__typename, 'id'].filter(v => v).join('-') : values.id,
3136
title: (values.title === null || values.title === undefined) ? [__typename, 'title'].filter(v => v).join('-') : values.title,
3237
...(options.addTypename ? { __typename } : {})
3338
};
39+
return result;
3440
})(item, options)),
3541
...(options.addTypename ? { __typename } : {})
3642
};
43+
return result;
3744
})(item, options))
3845
};
46+
return result;
3947
}
4048

4149
operations.createAuthor = {};
4250
operations.createAuthor.variables = (values = {}, options = {}) => {
4351
const __typename = '';
4452
values = (({ input = undefined }) => ({ input }))(values);
45-
return {
53+
values.__typename = __typename;
54+
let result = {
4655
input: (AuthorInput)(values.input || undefined, options)
4756
};
57+
return result;
4858
}
4959
operations.createAuthor.data = (values = {}, options = {}) => {
5060
const __typename = '';
5161
values = (({ createAuthor = null }) => ({ createAuthor }))(values);
52-
return {
62+
values.__typename = __typename;
63+
let result = {
5364
createAuthor: ((values = {}, options = {}) => {
5465
const __typename = 'Author';
5566
values = (({ id = null, name = null, description = null, books = null }) => ({ id, name, description, books }))(values);
56-
return {
67+
values.__typename = __typename;
68+
let result = {
5769
id: (values.id === null || values.id === undefined) ? [__typename, 'id'].filter(v => v).join('-') : values.id,
5870
name: (values.name === null || values.name === undefined) ? [__typename, 'name'].filter(v => v).join('-') : values.name,
5971
description: values.description,
6072
books: (values.books || []).map(item => ((values = {}, options = {}) => {
6173
const __typename = 'Book';
6274
values = (({ id = null, title = null }) => ({ id, title }))(values);
63-
return {
75+
values.__typename = __typename;
76+
let result = {
6477
id: (values.id === null || values.id === undefined) ? [__typename, 'id'].filter(v => v).join('-') : values.id,
6578
title: (values.title === null || values.title === undefined) ? [__typename, 'title'].filter(v => v).join('-') : values.title,
6679
...(options.addTypename ? { __typename } : {})
6780
};
81+
return result;
6882
})(item, options)),
6983
...(options.addTypename ? { __typename } : {})
7084
};
85+
return result;
7186
})(values.createAuthor || undefined, options)
7287
};
88+
return result;
7389
}
7490

7591
const BookInput = (values = {}, options = {}) => {
7692
const __typename = 'BookInput';
7793
values = (({ title = undefined }) => ({ title }))(values);
78-
return {
94+
values.__typename = __typename;
95+
let result = {
7996
title: (values.title === null || values.title === undefined) ? [__typename, 'title'].filter(v => v).join('-') : values.title
8097
};
98+
return result;
8199
}
82100

83101
const AuthorInput = (values = {}, options = {}) => {
84102
const __typename = 'AuthorInput';
85103
values = (({ name = undefined, description = undefined, books = undefined }) => ({ name, description, books }))(values);
86-
return {
104+
values.__typename = __typename;
105+
let result = {
87106
name: (values.name === null || values.name === undefined) ? [__typename, 'name'].filter(v => v).join('-') : values.name,
88107
description: values.description,
89108
books: (values.books || []).map(item => (BookInput)(item, options))
90109
};
110+
return result;
91111
}

0 commit comments

Comments
 (0)