Skip to content

Commit

Permalink
Stop flattening/refragmenting queries
Browse files Browse the repository at this point in the history
  • Loading branch information
josephsavona committed Nov 23, 2015
1 parent cb0c663 commit 1c4312d
Show file tree
Hide file tree
Showing 84 changed files with 902 additions and 1,065 deletions.
13 changes: 7 additions & 6 deletions scripts/babel-relay-plugin/lib/RelayQLPrinter.js
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,8 @@ module.exports = function (t, options) {
fieldName: t.valueToNode(rootField.getName()),
kind: t.valueToNode('Query'),
metadata: objectify(metadata),
name: t.valueToNode(query.getName())
name: t.valueToNode(query.getName()),
type: t.valueToNode(rootFieldType.getName({ modifiers: false }))
});
}
}, {
Expand Down Expand Up @@ -187,7 +188,7 @@ module.exports = function (t, options) {
kind: t.valueToNode('Fragment'),
metadata: metadata,
name: t.valueToNode(fragment.getName()),
type: t.valueToNode(fragmentType.getName({ modifiers: true }))
type: t.valueToNode(fragmentType.getName({ modifiers: false }))
});
}
}, {
Expand Down Expand Up @@ -219,7 +220,7 @@ module.exports = function (t, options) {
kind: t.valueToNode('Mutation'),
metadata: objectify(metadata),
name: t.valueToNode(mutation.getName()),
responseType: t.valueToNode(rootFieldType.getName({ modifiers: true }))
responseType: t.valueToNode(rootFieldType.getName({ modifiers: false }))
});
}
}, {
Expand Down Expand Up @@ -251,7 +252,7 @@ module.exports = function (t, options) {
kind: t.valueToNode('Subscription'),
metadata: objectify(metadata),
name: t.valueToNode(subscription.getName()),
responseType: t.valueToNode(rootFieldType.getName({ modifiers: true }))
responseType: t.valueToNode(rootFieldType.getName({ modifiers: false }))
});
}
}, {
Expand Down Expand Up @@ -321,7 +322,6 @@ module.exports = function (t, options) {
var fieldType = field.getType();

var metadata = {};
metadata.parentType = parent.getType().getName({ modifiers: false });
var requisiteFields = {};
var idFragment = undefined;
if (fieldType.hasField(FIELDS.id)) {
Expand Down Expand Up @@ -380,7 +380,8 @@ module.exports = function (t, options) {
directives: this.printDirectives(field.getDirectives()),
fieldName: t.valueToNode(field.getName()),
kind: t.valueToNode('Field'),
metadata: objectify(metadata)
metadata: objectify(metadata),
type: t.valueToNode(fieldType.getName({ modifiers: false }))
});
}
}, {
Expand Down
10 changes: 5 additions & 5 deletions scripts/babel-relay-plugin/src/RelayQLPrinter.js
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,7 @@ module.exports = function(t: any, options: PrinterOptions): Function {
kind: t.valueToNode('Query'),
metadata: objectify(metadata),
name: t.valueToNode(query.getName()),
type: t.valueToNode(rootFieldType.getName({modifiers: false})),
});
}

Expand Down Expand Up @@ -202,7 +203,7 @@ module.exports = function(t: any, options: PrinterOptions): Function {
kind: t.valueToNode('Fragment'),
metadata,
name: t.valueToNode(fragment.getName()),
type: t.valueToNode(fragmentType.getName({modifiers: true})),
type: t.valueToNode(fragmentType.getName({modifiers: false})),
});
}

Expand Down Expand Up @@ -243,7 +244,7 @@ module.exports = function(t: any, options: PrinterOptions): Function {
kind: t.valueToNode('Mutation'),
metadata: objectify(metadata),
name: t.valueToNode(mutation.getName()),
responseType: t.valueToNode(rootFieldType.getName({modifiers: true})),
responseType: t.valueToNode(rootFieldType.getName({modifiers: false})),
});
}

Expand Down Expand Up @@ -284,7 +285,7 @@ module.exports = function(t: any, options: PrinterOptions): Function {
kind: t.valueToNode('Subscription'),
metadata: objectify(metadata),
name: t.valueToNode(subscription.getName()),
responseType: t.valueToNode(rootFieldType.getName({modifiers: true})),
responseType: t.valueToNode(rootFieldType.getName({modifiers: false})),
});
}

Expand Down Expand Up @@ -379,9 +380,7 @@ module.exports = function(t: any, options: PrinterOptions): Function {
isPlural?: boolean;
isRequisite?: boolean;
isUnionOrInterface?: boolean;
parentType?: ?string;
} = {};
metadata.parentType = parent.getType().getName({modifiers: false});
const requisiteFields = {};
let idFragment;
if (fieldType.hasField(FIELDS.id)) {
Expand Down Expand Up @@ -446,6 +445,7 @@ module.exports = function(t: any, options: PrinterOptions): Function {
fieldName: t.valueToNode(field.getName()),
kind: t.valueToNode('Field'),
metadata: objectify(metadata),
type: t.valueToNode(fieldType.getName({modifiers: false})),
});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,23 +20,24 @@ var foo = (function (RQL_0) {
fieldName: "id",
kind: "Field",
metadata: {
parentType: "Node",
isRequisite: true
}
},
type: "String"
}, {
fieldName: "__typename",
kind: "Field",
metadata: {
parentType: "Node",
isGenerated: true,
isRequisite: true
}
},
type: "String"
}],
fieldName: "node",
kind: "Query",
metadata: {
identifyingArgName: "id"
},
name: "Args"
name: "Args",
type: "Node"
};
})(userID);
52 changes: 26 additions & 26 deletions scripts/babel-relay-plugin/src/__fixtures__/argsValues.fixture
Original file line number Diff line number Diff line change
Expand Up @@ -38,18 +38,18 @@ var foo = (function () {
fieldName: "id",
kind: "Field",
metadata: {
parentType: "Node",
isGenerated: true,
isRequisite: true
}
},
type: "String"
}, {
fieldName: "__typename",
kind: "Field",
metadata: {
parentType: "Node",
isGenerated: true,
isRequisite: true
}
},
type: "String"
}, {
children: [{
calls: [{
Expand Down Expand Up @@ -101,9 +101,9 @@ var foo = (function () {
fieldName: "id",
kind: "Field",
metadata: {
parentType: "User",
isRequisite: true
}
},
type: "String"
}, {
calls: [{
kind: "Call",
Expand All @@ -124,74 +124,73 @@ var foo = (function () {
}],
fieldName: "firstName",
kind: "Field",
metadata: {
parentType: "User"
}
metadata: {},
type: "String"
}],
fieldName: "node",
kind: "Field",
metadata: {
parentType: "UserConnectionEdge",
inferredRootCallName: "node",
inferredPrimaryKey: "id",
isRequisite: true
}
},
type: "User"
}, {
fieldName: "cursor",
kind: "Field",
metadata: {
parentType: "UserConnectionEdge",
isGenerated: true,
isRequisite: true
}
},
type: "String"
}],
fieldName: "edges",
kind: "Field",
metadata: {
parentType: "UserConnection",
isPlural: true
}
},
type: "UserConnectionEdge"
}, {
children: [{
fieldName: "hasNextPage",
kind: "Field",
metadata: {
parentType: "PageInfo",
isGenerated: true,
isRequisite: true
}
},
type: "Boolean"
}, {
fieldName: "hasPreviousPage",
kind: "Field",
metadata: {
parentType: "PageInfo",
isGenerated: true,
isRequisite: true
}
},
type: "Boolean"
}],
fieldName: "pageInfo",
kind: "Field",
metadata: {
parentType: "UserConnection",
isGenerated: true,
isRequisite: true
}
},
type: "PageInfo"
}],
fieldName: "friends",
kind: "Field",
metadata: {
parentType: "User",
isConnection: true,
isFindable: true
}
},
type: "UserConnection"
}, {
fieldName: "id",
kind: "Field",
metadata: {
parentType: "User",
isGenerated: true,
isRequisite: true
}
},
type: "String"
}],
hash: "/GeJm4rh",
kind: "Fragment",
Expand All @@ -206,6 +205,7 @@ var foo = (function () {
metadata: {
identifyingArgName: "id"
},
name: "Args"
name: "Args",
type: "Node"
};
})();
Original file line number Diff line number Diff line change
Expand Up @@ -29,24 +29,25 @@ var foo = (function () {
fieldName: "id",
kind: "Field",
metadata: {
parentType: "Node",
isRequisite: true
}
},
type: "String"
}, {
fieldName: "__typename",
kind: "Field",
metadata: {
parentType: "Node",
isGenerated: true,
isRequisite: true
}
},
type: "String"
}],
fieldName: "nodes",
kind: "Query",
metadata: {
isPlural: true,
identifyingArgName: "ids"
},
name: "Args"
name: "Args",
type: "Node"
};
})();
Original file line number Diff line number Diff line change
Expand Up @@ -23,74 +23,74 @@ var x = (function () {
fieldName: 'id',
kind: 'Field',
metadata: {
parentType: 'User',
isRequisite: true
}
},
type: 'String'
}],
fieldName: 'node',
kind: 'Field',
metadata: {
parentType: 'UserConnectionEdge',
inferredRootCallName: 'node',
inferredPrimaryKey: 'id',
isRequisite: true
}
},
type: 'User'
}, {
fieldName: 'cursor',
kind: 'Field',
metadata: {
parentType: 'UserConnectionEdge',
isGenerated: true,
isRequisite: true
}
},
type: 'String'
}],
fieldName: 'edges',
kind: 'Field',
metadata: {
parentType: 'UserConnection',
isPlural: true
}
},
type: 'UserConnectionEdge'
}, {
children: [{
fieldName: 'hasNextPage',
kind: 'Field',
metadata: {
parentType: 'PageInfo',
isGenerated: true,
isRequisite: true
}
},
type: 'Boolean'
}, {
fieldName: 'hasPreviousPage',
kind: 'Field',
metadata: {
parentType: 'PageInfo',
isGenerated: true,
isRequisite: true
}
},
type: 'Boolean'
}],
fieldName: 'pageInfo',
kind: 'Field',
metadata: {
parentType: 'UserConnection',
isGenerated: true,
isRequisite: true
}
},
type: 'PageInfo'
}],
fieldName: 'friends',
kind: 'Field',
metadata: {
parentType: 'User',
isConnection: true,
isFindable: true
}
},
type: 'UserConnection'
}, {
fieldName: 'id',
kind: 'Field',
metadata: {
parentType: 'User',
isGenerated: true,
isRequisite: true
}
},
type: 'String'
}],
hash: 'm+iXTD96',
kind: 'Fragment',
Expand Down
Loading

0 comments on commit 1c4312d

Please sign in to comment.