Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
throw new Error('typeName, fieldName, and fieldType are required for ExtendSchema');
}
typeName = typeName.trim();
fieldName = fieldName.trim();
const matches = fieldName.match(/^\w+/);
// If no field name exists, then ignore creating the plugin
if (isNil(matches)) {
throw new Error('Unable to create ExtendSchema plugin because a field name'
+ ' was not provided or is not in correct form. fieldname: ' + fieldName);
}
const fieldNameWithoutParams = matches[0];
return makeExtendSchemaPlugin(build => {
return {
typeDefs: gql`
${additionalGraphql}
extend type ${typeName} {
${fieldName}: ${fieldType}
}
`,
resolvers: {
[typeName]: {
[fieldNameWithoutParams]: async (query, args, context, resolveInfo) => {
return await resolver(query, args, context, resolveInfo, build);
},
},
},
};
const { makeExtendSchemaPlugin, gql } = require("graphile-utils");
const PassportLoginPlugin = makeExtendSchemaPlugin(build => ({
typeDefs: gql`
input RegisterInput {
username: String!
email: String!
password: String!
name: String
avatarUrl: String
}
type RegisterPayload {
user: User! @pgField
}
input LoginInput {
username: String!
password: String!