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

fix(procedures): support procedures returning setof composite #61

Merged
merged 3 commits into from
Sep 5, 2017
Merged
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
156 changes: 78 additions & 78 deletions packages/graphile-build-pg/src/plugins/PgTablesPlugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -209,92 +209,92 @@ export default (function PgTablesPlugin(builder, { pgInflection: inflection }) {
},
}
);
const EdgeType = newWithHooks(
GraphQLObjectType,
{
description: `A \`${tableTypeName}\` edge in the connection.`,
name: inflection.edge(TableType.name),
fields: ({ fieldWithHooks, recurseDataGeneratorsForField }) => {
recurseDataGeneratorsForField("node");
return {
cursor: fieldWithHooks("cursor", ({ addDataGenerator }) => {
addDataGenerator(() => ({
usesCursor: [true],
}));
return {
description: "A cursor for use in pagination.",
type: Cursor,
resolve(data) {
return (
data.__cursor && base64(JSON.stringify(data.__cursor))
);
},
};
}),
node: {
description: `The \`${tableTypeName}\` at the end of the edge.`,
type: new GraphQLNonNull(TableType),
}
const EdgeType = newWithHooks(
GraphQLObjectType,
{
description: `A \`${tableTypeName}\` edge in the connection.`,
name: inflection.edge(TableType.name),
fields: ({ fieldWithHooks, recurseDataGeneratorsForField }) => {
recurseDataGeneratorsForField("node");
return {
cursor: fieldWithHooks("cursor", ({ addDataGenerator }) => {
addDataGenerator(() => ({
usesCursor: [true],
}));
return {
description: "A cursor for use in pagination.",
type: Cursor,
resolve(data) {
return data;
return (
data.__cursor && base64(JSON.stringify(data.__cursor))
);
},
};
}),
node: {
description: `The \`${tableTypeName}\` at the end of the edge.`,
type: new GraphQLNonNull(TableType),
resolve(data) {
return data;
},
};
},
},
};
},
{
isEdgeType: true,
isPgRowEdgeType: true,
nodeType: TableType,
pgIntrospection: table,
}
);
const PageInfo = getTypeByName("PageInfo");
/*const ConnectionType = */
newWithHooks(
GraphQLObjectType,
{
description: `A connection to a list of \`${tableTypeName}\` values.`,
name: inflection.connection(TableType.name),
fields: ({ recurseDataGeneratorsForField }) => {
recurseDataGeneratorsForField("edges");
recurseDataGeneratorsForField("nodes");
recurseDataGeneratorsForField("pageInfo");
return {
nodes: {
description: `A list of \`${tableTypeName}\` objects.`,
type: new GraphQLNonNull(new GraphQLList(TableType)),
resolve(data) {
return data.data;
},
},
{
isEdgeType: true,
isPgRowEdgeType: true,
nodeType: TableType,
pgIntrospection: table,
}
);
const PageInfo = getTypeByName("PageInfo");
/*const ConnectionType = */
newWithHooks(
GraphQLObjectType,
{
description: `A connection to a list of \`${tableTypeName}\` values.`,
name: inflection.connection(TableType.name),
fields: ({ recurseDataGeneratorsForField }) => {
recurseDataGeneratorsForField("edges");
recurseDataGeneratorsForField("nodes");
recurseDataGeneratorsForField("pageInfo");
return {
nodes: {
description: `A list of \`${tableTypeName}\` objects.`,
type: new GraphQLNonNull(new GraphQLList(TableType)),
resolve(data) {
return data.data;
},
edges: {
description: `A list of edges which contains the \`${tableTypeName}\` and cursor to aid in pagination.`,
type: new GraphQLNonNull(
new GraphQLList(new GraphQLNonNull(EdgeType))
),
resolve(data) {
return data.data;
},
},
edges: {
description: `A list of edges which contains the \`${tableTypeName}\` and cursor to aid in pagination.`,
type: new GraphQLNonNull(
new GraphQLList(new GraphQLNonNull(EdgeType))
),
resolve(data) {
return data.data;
},
pageInfo: PageInfo && {
description: "Information to aid in pagination.",
type: new GraphQLNonNull(PageInfo),
resolve(data) {
return data;
},
},
pageInfo: PageInfo && {
description: "Information to aid in pagination.",
type: new GraphQLNonNull(PageInfo),
resolve(data) {
return data;
},
};
},
},
};
},
{
isConnectionType: true,
isPgRowConnectionType: true,
edgeType: EdgeType,
nodeType: TableType,
pgIntrospection: table,
}
);
}
},
{
isConnectionType: true,
isPgRowConnectionType: true,
edgeType: EdgeType,
nodeType: TableType,
pgIntrospection: table,
}
);
pgGqlTypeByTypeId[tablePgType.id] = TableType;
pgGqlInputTypeByTypeId[tablePgType.id] = TableInputType;
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ query {
typesQuery(a: "50", b: false, c: "xyz", d: [1, 2, 3], e: "{\"a\":1,\"b\":2,\"c\":3}", f: { start: { value: 1, inclusive: false }, end: { value: 5, inclusive: false } })
empty: typesQuery(a: "50", b: false, c: "", d: [], e: "{}", f: {})
compoundTypeQuery(object: { a: 419, b: "easy cheesy baked potatoes", c: RED, e: BAR_FOO, fooBar: 8 }) { a b c d e fooBar }
compoundTypeSetQuery { edges { cursor node { a b c d e fooBar } } }
tableQuery(id: 5) { nodeId id headline authorId }
tableSetQuery { edges { cursor node { name } } }
tableSetQueryWithOffset: tableSetQuery(before: "WyJuYXR1cmFsIiw1XQ==", after: "WyJuYXR1cmFsIiwzXQ==") { edges { cursor node { name } } }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1734,6 +1734,21 @@ Object {
"e": "BAR_FOO",
"fooBar": 8,
},
"compoundTypeSetQuery": Object {
"edges": Array [
Object {
"cursor": "WyJuYXR1cmFsIiwxXQ==",
"node": Object {
"a": 1,
"b": "2",
"c": "BLUE",
"d": null,
"e": "_0_BAR",
"fooBar": 7,
},
},
],
},
"empty": false,
"intSetQuery": Object {
"edges": Array [
Expand Down
Loading