These are chat archives for graphql-java/graphql-java

26th
Apr 2017
Vi-ka
@Vi-dot
Apr 26 2017 08:18
hello,
I wonder how we can update or insert an entire GraphQL Object in one time with mutation ?
By example this doesn't work :
GraphQLObjectType myObjectType = ...;

GraphQLObjectType mutationType = GraphQLObjectType.newObject()
    .name("MutationType")
    .field(newFieldDefinition()
        .name("insertObject")
        .type(myObjectType))
        .argument(newArgument()
            .name("newObject")
            .type(myObjectType)) //this line doesn't work
    .build();
Bojan Tomić
@kaqqao
Apr 26 2017 09:05
Did you check why it isn't working? The error is quite clear: you can't use an output type as an input type. You need to make myInputObjectType that has the same structure as myObjectType. This is because input and output types have different constraints in GraphQL
Vi-ka
@Vi-dot
Apr 26 2017 09:33
thx @kaqqao there is an example of an inputType ?
Bojan Tomić
@kaqqao
Apr 26 2017 11:22
It's really no different than creating an GraphQLObjectType, just use the exact same style to create an GraphQLInputObjectType
Vi-ka
@Vi-dot
Apr 26 2017 12:44
Thanks I try that ! :)