public void TestSubscriptionQueryGeneration() { // Arrange var selectionSet = _fieldBuilder.GenerateSelectionSet(typeof(MessageSubscription)); string expected = "{\"query\":\"subscription newMessage{newMessage{body sender}}\"}"; // Act var actual = _queryGenerator.GenerateQuery(GraphQLOperationType.Subscription, selectionSet); // Assert Assert.Equal(expected, actual); }
/// <summary> /// Builds a GraphQL mutation from the specified <see cref="Type"/> and the <see cref="GraphQLQueryArgument"/>s /// </summary> /// <typeparam name="T">The type to generate the mutation from</typeparam> /// <param name="queryGenerator">The queryGenerator used to generate the query</param> /// <param name="fieldBuilder">The fieldBuilder used for examining the type</param> /// <param name="arguments">The argument values which is inserted using a variable on specified arguments with the <see cref="GraphQLArgumentsAttribute"/></param> /// <returns>The generated mutation</returns> public static string GetMutation <T>(this IGraphQLQueryGeneratorFromFields queryGenerator, IGraphQLFieldBuilder fieldBuilder, params GraphQLQueryArgument[] arguments) { if (queryGenerator == null) { throw new ArgumentNullException(nameof(queryGenerator)); } if (fieldBuilder == null) { throw new ArgumentNullException(nameof(fieldBuilder)); } var selectionSet = fieldBuilder.GenerateSelectionSet(typeof(T)); return(queryGenerator.GenerateQuery(GraphQLOperationType.Mutation, selectionSet, arguments)); }
public override void RunBenchmark <T>() { _fieldBuilder.GenerateSelectionSet(typeof(T)); }
private static IEnumerable <ValidationError> ValidateGraphQLType <T>(this GraphQLIntrospectionSchema graphQLIntrospectionSchema, GraphQLOperationType operationType, IGraphQLFieldBuilder fieldBuilder) { if (fieldBuilder is null) { throw new ArgumentNullException(nameof(fieldBuilder)); } var validator = new GraphQLValidation(); return(validator.ValidateGraphQLSelectionSet(graphQLIntrospectionSchema, operationType, fieldBuilder.GenerateSelectionSet(typeof(T)))); }