Initialisation
Added the packages and files for the backend server
This commit is contained in:
61
node_modules/@graphql-tools/utils/esm/stub.js
generated
vendored
Normal file
61
node_modules/@graphql-tools/utils/esm/stub.js
generated
vendored
Normal file
@@ -0,0 +1,61 @@
|
||||
import { GraphQLObjectType, GraphQLInterfaceType, GraphQLInputObjectType, GraphQLString, GraphQLInt, GraphQLFloat, GraphQLBoolean, GraphQLID, Kind, GraphQLList, GraphQLNonNull, } from 'graphql';
|
||||
export function createNamedStub(name, type) {
|
||||
let constructor;
|
||||
if (type === 'object') {
|
||||
constructor = GraphQLObjectType;
|
||||
}
|
||||
else if (type === 'interface') {
|
||||
constructor = GraphQLInterfaceType;
|
||||
}
|
||||
else {
|
||||
constructor = GraphQLInputObjectType;
|
||||
}
|
||||
return new constructor({
|
||||
name,
|
||||
fields: {
|
||||
_fake: {
|
||||
type: GraphQLString,
|
||||
},
|
||||
},
|
||||
});
|
||||
}
|
||||
export function createStub(node, type) {
|
||||
switch (node.kind) {
|
||||
case Kind.LIST_TYPE:
|
||||
return new GraphQLList(createStub(node.type, type));
|
||||
case Kind.NON_NULL_TYPE:
|
||||
return new GraphQLNonNull(createStub(node.type, type));
|
||||
default:
|
||||
if (type === 'output') {
|
||||
return createNamedStub(node.name.value, 'object');
|
||||
}
|
||||
return createNamedStub(node.name.value, 'input');
|
||||
}
|
||||
}
|
||||
export function isNamedStub(type) {
|
||||
if ('getFields' in type) {
|
||||
const fields = type.getFields();
|
||||
// eslint-disable-next-line no-unreachable-loop
|
||||
for (const fieldName in fields) {
|
||||
const field = fields[fieldName];
|
||||
return field.name === '_fake';
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
export function getBuiltInForStub(type) {
|
||||
switch (type.name) {
|
||||
case GraphQLInt.name:
|
||||
return GraphQLInt;
|
||||
case GraphQLFloat.name:
|
||||
return GraphQLFloat;
|
||||
case GraphQLString.name:
|
||||
return GraphQLString;
|
||||
case GraphQLBoolean.name:
|
||||
return GraphQLBoolean;
|
||||
case GraphQLID.name:
|
||||
return GraphQLID;
|
||||
default:
|
||||
return type;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user