Package net.morimekta.providence.graphql
Class GQLDefinition
- java.lang.Object
-
- net.morimekta.providence.graphql.GQLDefinition
-
@Immutable public class GQLDefinition extends java.lang.Object
A GQL service is a collection of zero or more 'queries' and zero or more 'mutations'. The query and mutation distinction is meant to represent reading and writing operations, but in reality they distinguish parallel and serial execution, in case the query contains more than one base entry.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
GQLDefinition.Builder
Builder for setting up a GraphQL definition.
-
Constructor Summary
Constructors Constructor Description GQLDefinition(PService query, PService mutation, java.util.Collection<PField<?>> idFields)
Deprecated.Use Builder.GQLDefinition(PService query, PService mutation, java.util.Collection<PField<?>> idFields, java.util.Collection<PUnionDescriptor<?>> asInterface)
Deprecated.Use Builder.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static GQLDefinition.Builder
builder()
net.morimekta.providence.graphql.introspection.Schema
getIntrospectionSchema()
Return the introspection schema for this definition.net.morimekta.providence.graphql.introspection.Type
getIntrospectionType(java.lang.String name)
Get the introspection type for a defined type.net.morimekta.providence.graphql.introspection.Type
getIntrospectionType(PDescriptor descriptor, boolean isInput)
Get introspection type for a given descriptor.PService
getMutation()
Get mutation by name, e.g. for gql queries like this:PService
getQuery()
Get query, e.g. for gql queries like this:java.lang.String
getSchema()
Get a defined schema from the GQL service.PDescriptor
getType(java.lang.String name)
Get a type used in the GQL service.boolean
isIgnoredField(PField<?> field)
If the field should be ignored.boolean
isIgnoredType(PDescriptor descriptor)
If the type should be ignored.
-
-
-
Constructor Detail
-
GQLDefinition
@Deprecated public GQLDefinition(@Nonnull PService query, @Nullable PService mutation, @Nonnull java.util.Collection<PField<?>> idFields)
Deprecated.Use Builder.Create a graphql definition instance.- Parameters:
query
- The query service. Mandatory.mutation
- The mutation service.idFields
- Collection if ID fields.
-
GQLDefinition
@Deprecated public GQLDefinition(@Nonnull PService query, @Nullable PService mutation, @Nonnull java.util.Collection<PField<?>> idFields, @Nonnull java.util.Collection<PUnionDescriptor<?>> asInterface)
Deprecated.Use Builder.Create a graphql definition instance.- Parameters:
query
- The query service. Mandatory.mutation
- The mutation service.idFields
- Collection if ID fields.asInterface
- Collection of unions to be
-
-
Method Detail
-
builder
public static GQLDefinition.Builder builder()
-
getQuery
@Nonnull public PService getQuery()
Get query, e.g. for gql queries like this:{ hero(id:1001) { name } }
- Returns:
- The query service.
-
getMutation
@Nullable public PService getMutation()
Get mutation by name, e.g. for gql queries like this:mutation HeroStore { deleteHero(id:1001) { name } }
- Returns:
- The mutation service.
-
isIgnoredField
public boolean isIgnoredField(PField<?> field)
If the field should be ignored. This means not allowed in fragments or selection sets.- Parameters:
field
- The field to check.- Returns:
- True if the field should be ignored.
-
isIgnoredType
public boolean isIgnoredType(PDescriptor descriptor)
If the type should be ignored.- Parameters:
descriptor
- The type- Returns:
- If the type should be ignored.
-
getType
public PDescriptor getType(@Nonnull java.lang.String name)
Get a type used in the GQL service.- Parameters:
name
- The name of the type.- Returns:
- The type description, enum or message.
-
getIntrospectionType
@Nullable public net.morimekta.providence.graphql.introspection.Type getIntrospectionType(@Nonnull java.lang.String name)
Get the introspection type for a defined type.- Parameters:
name
- The type name.- Returns:
- Introspection type, or null if not defined in service.
-
getIntrospectionType
@Nonnull public net.morimekta.providence.graphql.introspection.Type getIntrospectionType(@Nonnull PDescriptor descriptor, boolean isInput)
Get introspection type for a given descriptor.- Parameters:
descriptor
- The descriptor to get introspection type for.isInput
- If the type should be an input type.- Returns:
- The introspection type.
-
getSchema
public java.lang.String getSchema()
Get a defined schema from the GQL service.- Returns:
- The GQL schema.
-
getIntrospectionSchema
@Nonnull public net.morimekta.providence.graphql.introspection.Schema getIntrospectionSchema()
Return the introspection schema for this definition.- Returns:
- The schema.
-
-