Closed acomito closed 7 years ago
Seems like I'll find the answer here:
https://github.com/janikvonrotz/meteor-apollo-accounts-example/blob/master/server/schema.js
Any other hints would be appreciated
That is an old example, now just create the User schema
@nicolaslopezj I do have a type User schema but meteor-apollo-accounts doesn't seem to be aware of it. Where do the two connect? The User schema is registered (I can do my own mutations on it) but createAccount() is not aware of it, and so it throws an errror with everything other than the default schema (profile: { Name: String } }
import { createApolloServer } from 'meteor/apollo';
import { makeExecutableSchema } from 'graphql-tools';
import { typeDefs, resolvers } from '/imports/api/schema';
import {loadSchema, getSchema} from 'graphql-loader'
import {initAccounts} from 'meteor/nicolaslopezj:apollo-accounts'
import cors from 'cors';
//set options
// Load all accounts related resolvers and type definitions into graphql-loader
initAccounts({});
// Load all your resolvers and type definitions into graphql-loader
loadSchema({typeDefs, resolvers});
// Gets all the resolvers and type definitions loaded in graphql-loader
const schema = makeExecutableSchema(getSchema());
//create server
createApolloServer({ schema }, {
configServer: graphQLServer => graphQLServer.use(cors()),
});
Can you show me the error?
Variable "$profile" got invalid value {"cell":"42341","name":{"first":"fsadf","last":"fsfda"}}. In field "cell": Unknown field.
In graphiql my createUser mutation shows this:
username: String
email: String
password: HashedPassword
plainPassword: String
profile: CreateUserProfileInput
So somewhere along the line my schema is not getting into the packages mutations. I'm guessing that I'm missing something in my imports/startup/server/grapQL-config.js
or how I load my schemas in imports/api/schema.js
?
example here: https://github.com/acomito/spacebug-graphql.git
Are you defining the input CreateUserProfileInput
?
I have no explicitly set it. Where do you do that? Here?
//set options
const options = {
CreateUserProfileInput: `
name: Name!
`
};
// Load all accounts related resolvers and type definitions into graphql-loader
initAccounts(options);
Define it in your schema
input CreateUserProfileInput {
name: String!
otherField: String
}
ahh okay
That works now. What if I want to nest data I'm inserting?
type Name {
first: String
last: String
}
input CreateUserProfileInput {
name: Name
cell: String
}
Just define that type in other file
I saw that we can customize the profile here:
Is there any way to use objects? For instance if I need name to be an object like:
I have a user schema but just not sure the where/when/how to let meteor-apollo-accounts know about it: