3

I'm new to GraphQL and graphql-java. I'm trying to create this schema programmatically

type Query{name:String!}

I don't know how to make the name field not being null String! By default this is optional.

GraphQLObjectType queryType = GraphQLObjectType.newObject()
        .name("Query")
        .field(GraphQLFieldDefinition.newFieldDefinition()
                .name("name")
                .type(Scalars.GraphQLString)
                .dataFetcher(new StaticDataFetcher("Joe")))
        .build();

1 Answer 1

5
.type(GraphQLNonNull.nonNull(Scalars.GraphQLString))
Sign up to request clarification or add additional context in comments.

1 Comment

This should definitely be in the documentation! graphql-java.com/documentation/v11/schema

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.