Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Minimal API Support (v2.0) #143

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 68 commits into from
Nov 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
68 commits
Select commit Hold shift + click to select a range
6ed32c1
WIP, laid out the foundations for the field builders
kevin-carroll May 17, 2023
5a90476
WIP, building out extension methods for field builder
kevin-carroll May 20, 2023
50cfa1d
Merge branch 'master' into feature/55-minimalApi
kevin-carroll Jun 11, 2023
e82696b
WIP, delete extra file from merge
kevin-carroll Jun 11, 2023
9a82ecb
WIP, api extension methods completed.
kevin-carroll Jun 17, 2023
175af77
WIP, added directives to minimal api
kevin-carroll Jun 17, 2023
cc8105a
WIP, added tests for minimal API endpoints
kevin-carroll Jun 18, 2023
39a3ef6
WIP, working through templating
kevin-carroll Jun 18, 2023
fe68e46
WIP, renamed runtime templates to runtime definitions
kevin-carroll Jun 19, 2023
80de6cd
WIP, converted top level data into attributitons
kevin-carroll Jun 19, 2023
fdd42b6
WIP
kevin-carroll Jun 19, 2023
11a7a6d
WIP, basic invocation sequence complete
kevin-carroll Jun 25, 2023
d38cc8f
WIP, added support for static minimal api resolvers
kevin-carroll Jun 27, 2023
b690d28
WIP, added support for graph actions in minimal api
kevin-carroll Jun 27, 2023
3713674
WIP
kevin-carroll Jun 29, 2023
84b8336
WIP, execution tests for authentication for minimal api
kevin-carroll Jun 29, 2023
8ae20fd
WIP, added ITypedSchemaItem to IGraphField
kevin-carroll Jul 1, 2023
72ed3ec
WIP, stubbed out runtime schema item validation
kevin-carroll Jul 1, 2023
c8c5338
WIP, decoupled resolver metadata from primary field template
kevin-carroll Jul 2, 2023
102588b
WIP, decoupled resolver metadata from parent template
kevin-carroll Jul 3, 2023
be0a941
WIP, decoupled resolver metadata from gql args and abstracted param info
kevin-carroll Jul 3, 2023
49b80f6
WIP, removed objectType from resolver metadata declarations
kevin-carroll Jul 3, 2023
eb860a3
WIP
kevin-carroll Jul 3, 2023
16dff9b
WIP, removed argument modifiers from graphargument
kevin-carroll Jul 4, 2023
22dbae6
WIP, union list bug
kevin-carroll Jul 4, 2023
2946a89
WIP, fixed batch type extension of interface regression
kevin-carroll Jul 4, 2023
4093072
WIP, ready to remove global providers
kevin-carroll Jul 4, 2023
0bf3a18
WIP, primary library switched off of global type providers
kevin-carroll Jul 11, 2023
b4b261c
WIP, global providers removed. All tests passed.
kevin-carroll Jul 11, 2023
1320b83
WIP, Combined global union and scalar instantiators
kevin-carroll Jul 12, 2023
6e0c0d6
WIP, clean up and file reorg
kevin-carroll Jul 13, 2023
f3f3fac
WIP, internal file reorg, namespace fixes
kevin-carroll Jul 13, 2023
cb8b44e
WIP, clean up
kevin-carroll Jul 13, 2023
8febe44
WIP, unit tests for GlobalTypes class
kevin-carroll Jul 15, 2023
f295e0d
WIP, ready for injected service tests
kevin-carroll Jul 15, 2023
ebada7e
WIP, unit test org updates
kevin-carroll Jul 15, 2023
9397db7
WIP, basics of injected services are working
kevin-carroll Jul 15, 2023
916505b
WIP, simple minimal api directives working
kevin-carroll Jul 15, 2023
4cc1b6b
WIP, runtime directive arguments fixed
kevin-carroll Jul 16, 2023
9cf5102
WIP, minimal api security check tests added. Fixed batches as well.
kevin-carroll Jul 16, 2023
07ca7ca
WIP, reworked FieldResolutionContext and DirectiveResolutionContext
kevin-carroll Jul 17, 2023
0f32f4a
WIP, clean up of TestServer method names
kevin-carroll Jul 18, 2023
173c6e4
WIP, created DirectiveContextBuilder in test server
kevin-carroll Jul 19, 2023
f23782b
WIP, resolver context injection tests done
kevin-carroll Jul 22, 2023
2cbc445
WIP, cleaned up InternalName properties and separated it from indexab…
kevin-carroll Jul 22, 2023
2db7223
WIP, clean up from internal name restructure
kevin-carroll Jul 22, 2023
456a55a
WIP, included support for [Union] attribute on GraphFieldTemplateBase.
kevin-carroll Jul 23, 2023
0022b12
WIP, internal name tests and type maker fixes
kevin-carroll Jul 23, 2023
8de7b4c
WIP
kevin-carroll Jul 24, 2023
6848a9e
WIP, added union support to runtme apis
kevin-carroll Jul 24, 2023
d2762a3
WIP
kevin-carroll Jul 24, 2023
d37f645
WIP, centralized minimal api overloads to reduce regressions
kevin-carroll Jul 25, 2023
260e29b
WIP, more tests
kevin-carroll Jul 26, 2023
6cb53ec
WIP, more unit tests for minimal api coverage
kevin-carroll Jul 26, 2023
1690204
WIP, moar unit tests.
kevin-carroll Jul 29, 2023
adf4bbe
WIP, minimal api subscription templating done
kevin-carroll Jul 30, 2023
678e40f
Merge branch 'master' into feature/55-minimalApi
kevin-carroll Jul 30, 2023
fff1f81
WIP, removed global schema registration variables
kevin-carroll Jul 30, 2023
153711c
WIP, setup static classes for subscription action results
kevin-carroll Jul 30, 2023
3fb12dc
WIP, more tests for subscriptions
kevin-carroll Aug 3, 2023
d67f2f6
WIP
kevin-carroll Aug 4, 2023
b6e8ec7
WIP
kevin-carroll Aug 4, 2023
0195667
WIP
kevin-carroll Aug 5, 2023
f308248
WIP, added release branch as PR target
kevin-carroll Aug 5, 2023
7278dd5
Merge branch 'master' into feature/55-minimalApi
kevin-carroll Aug 27, 2023
fd943c6
Merge branch 'master' into feature/55-minimalApi
kevin-carroll Nov 24, 2023
e6aef96
WIP, fix location of new test data objects from merge
kevin-carroll Nov 24, 2023
2035548
Merge branch 'master' into feature/55-minimalApi
kevin-carroll Nov 24, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
1 change: 1 addition & 0 deletions 1 .github/workflows/ci-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ on:
pull_request:
branches:
- master
- 'release/**'

env:
SLN_PATH: ./src/graphql-aspnet.sln
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,12 @@ namespace GraphQL.AspNet.StarwarsAPI.Common.GraphControllers
{
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Threading.Tasks;
using GraphQL.AspNet.Attributes;
using GraphQL.AspNet.Controllers;
using GraphQL.AspNet.Interfaces.Controllers;
using GraphQL.AspNet.Schemas.TypeSystem;
using GraphQL.AspNet.StarwarsAPI.Common.Model;
using GraphQL.AspNet.StarwarsAPI.Common.Services;
using Microsoft.AspNetCore.Authorization;

/// <summary>
/// A controller to handle search queries across the spectrum of the star wars universe.
Expand All @@ -42,7 +39,7 @@ public SearchController(IStarWarsDataService starWarsData)
/// </summary>
/// <param name="searchText">The text to search for.</param>
/// <returns>Task&lt;IGraphActionResult&gt;.</returns>
[QueryRoot("search","SearchResults", typeof(Droid), typeof(Human), typeof(Starship), TypeExpression = "[Type]")]
[QueryRoot("search", "SearchResults", typeof(Droid), typeof(Human), typeof(Starship), TypeExpression = "[Type]")]
[Description("Searches for the specified text as the name of a starship or character (not case sensitive).")]
public async Task<IGraphActionResult> GlobalSearch(string searchText = "*")
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ namespace GraphQL.AspNet.StarwarsAPI.Common.GraphControllers
using GraphQL.AspNet.Interfaces.Controllers;
using GraphQL.AspNet.StarwarsAPI.Common.Model;
using GraphQL.AspNet.StarwarsAPI.Common.Services;
using Microsoft.AspNetCore.Http;
using Microsoft.Extensions.DependencyInjection;

/// <summary>
/// A graph controller responsible for managing starship related data.
Expand Down Expand Up @@ -67,7 +69,6 @@ public async Task<IGraphActionResult> RetrieveStarship([FromGraphQL("id")] Graph
return this.Ok(starship);
}


/// <summary>
/// Retrieves a droid in the system by their id. Note the use of a different name for the parameter
/// between its exposure in the object graph vs. the formal parameter name used in the C# code.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net8.0;net7.0;netstandard2.0;</TargetFrameworks>
<TargetFrameworks>net8.0;net7.0;</TargetFrameworks>
<LangVersion>latest</LangVersion>
<NoWarn>$(NoWarn);1701;1702;1705;1591;NU1603</NoWarn>
<RootNamespace>GraphQL.AspNet.StarwarsAPI.Common</RootNamespace>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ public SubscriptionAttribute(string template, Type returnType)
/// be sure to supply any additional concrete types so that they may be included in the object graph.</param>
/// <param name="additionalTypes">Any additional types to include in the object graph on behalf of this method.</param>
public SubscriptionAttribute(string template, Type returnType, params Type[] additionalTypes)
: base(false, SchemaItemCollections.Subscription, template, returnType.AsEnumerable().Concat(additionalTypes).ToArray())
: base(false, SchemaItemCollections.Subscription, template, (new Type[] { returnType }).Concat(additionalTypes ?? Enumerable.Empty<Type>()).ToArray())
{
this.EventName = null;
}
Expand All @@ -93,15 +93,14 @@ public SubscriptionAttribute(string template, Type returnType, params Type[] add
/// <param name="template">The template naming scheme to use to generate a graph field from this method.</param>
/// <param name="unionTypeName">Name of the union type.</param>
/// <param name="unionTypeA">The first of two required types to include in the union.</param>
/// <param name="unionTypeB">The second of two required types to include in the union.</param>
/// <param name="additionalUnionTypes">Any additional union types to include.</param>
public SubscriptionAttribute(string template, string unionTypeName, Type unionTypeA, Type unionTypeB, params Type[] additionalUnionTypes)
public SubscriptionAttribute(string template, string unionTypeName, Type unionTypeA, params Type[] additionalUnionTypes)
: base(
false,
SchemaItemCollections.Subscription,
template,
unionTypeName,
unionTypeA.AsEnumerable().Concat(unionTypeB.AsEnumerable()).Concat(additionalUnionTypes).ToArray())
new Type[] { unionTypeA }.Concat(additionalUnionTypes ?? Enumerable.Empty<Type>()).ToArray())
{
this.EventName = null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ public SubscriptionRootAttribute(string template, Type returnType)
/// be sure to supply any additional concrete types so that they may be included in the object graph.</param>
/// <param name="additionalTypes">Any additional types to include in the object graph on behalf of this method.</param>
public SubscriptionRootAttribute(string template, Type returnType, params Type[] additionalTypes)
: base(true, SchemaItemCollections.Subscription, template, returnType.AsEnumerable().Concat(additionalTypes).ToArray())
: base(true, SchemaItemCollections.Subscription, template, (new Type[] { returnType }).Concat(additionalTypes ?? Enumerable.Empty<Type>()).ToArray())
{
this.EventName = null;
}
Expand All @@ -93,15 +93,14 @@ public SubscriptionRootAttribute(string template, Type returnType, params Type[]
/// <param name="template">The template naming scheme to use to generate a graph field from this method.</param>
/// <param name="unionTypeName">Name of the union type.</param>
/// <param name="unionTypeA">The first of two required types to include in the union.</param>
/// <param name="unionTypeB">The second of two required types to include in the union.</param>
/// <param name="additionalUnionTypes">Any additional union types.</param>
public SubscriptionRootAttribute(string template, string unionTypeName, Type unionTypeA, Type unionTypeB, params Type[] additionalUnionTypes)
public SubscriptionRootAttribute(string template, string unionTypeName, Type unionTypeA, params Type[] additionalUnionTypes)
: base(
true,
SchemaItemCollections.Subscription,
template,
unionTypeName,
unionTypeA.AsEnumerable().Concat(unionTypeB.AsEnumerable()).Concat(additionalUnionTypes).ToArray())
(new Type[] { unionTypeA }).Concat(additionalUnionTypes ?? Enumerable.Empty<Type>()).ToArray())
{
this.EventName = null;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,185 @@
// *************************************************************
// project: graphql-aspnet
// --
// repo: https://github.com/graphql-aspnet
// docs: https://graphql-aspnet.github.io
// --
// License: MIT
// *************************************************************

namespace GraphQL.AspNet.Configuration
{
using System;
using GraphQL.AspNet.Attributes;
using GraphQL.AspNet.Common;
using GraphQL.AspNet.Execution;
using GraphQL.AspNet.Interfaces.Configuration;
using GraphQL.AspNet.Interfaces.Schema.RuntimeDefinitions;
using GraphQL.AspNet.Schemas.Generation.RuntimeSchemaItemDefinitions;

/// <summary>
/// Extension methods for defining subscriptions via minimal api.
/// </summary>
public static partial class GraphQLRuntimeSubscriptionDefinitionExtensions
{
/// <summary>
/// Creates a new, explicitly resolvable field in the Subscription root object with the given path. This field cannot be
/// further extended or nested with other fields via the Mapping API.
/// </summary>
/// <param name="schemaBuilder">The builder representing the schema where this field
/// will be created.</param>
/// <param name="template">The template path string for his field. (e.g. <c>/path1/path2/path3</c>)</param>
/// <returns>IGraphQLFieldTemplate.</returns>
public static IGraphQLSubscriptionEnabledRuntimeResolvedFieldDefinition MapSubscription(this ISchemaBuilder schemaBuilder, string template)
{
Validation.ThrowIfNull(schemaBuilder, nameof(schemaBuilder));

return MapSubscription(
schemaBuilder.Options,
template,
null, // unionName
null as Delegate);
}

/// <summary>
/// Creates a new field in the Subscription object with the given path. This field can act as a
/// grouping field of other resolvable fields or be converted to an explicitly resolvable field itself.
/// </summary>
/// <param name="schemaBuilder">The builder representing the schema where this field
/// will be created.</param>
/// <param name="template">The template path string for his field. (e.g. <c>/path1/path2/path3</c>)</param>
/// <param name="resolverMethod">The resolver method to execute when this
/// field is requested.</param>
/// <returns>IGraphQLFieldTemplate.</returns>
public static IGraphQLSubscriptionEnabledRuntimeResolvedFieldDefinition MapSubscription(this ISchemaBuilder schemaBuilder, string template, Delegate resolverMethod)
{
Validation.ThrowIfNull(schemaBuilder, nameof(schemaBuilder));
return MapSubscription(
schemaBuilder.Options,
template,
null, // unionName
resolverMethod);
}

/// <summary>
/// Creates a new field in the Subscription object with the given path. This field can act as a
/// grouping field of other resolvable fields or be converted to an explicitly resolvable field itself.
/// </summary>
/// <param name="schemaBuilder">The builder representing the schema where this field
/// will be created.</param>
/// <param name="template">The template path string for his field. (e.g. <c>/path1/path2/path3</c>)</param>
/// <param name="unionName">Provide a name and this field will be declared to return a union. Use <see cref="GraphQLRuntimeSchemaItemDefinitionExtensions.AddPossibleTypes(IGraphQLRuntimeResolvedFieldDefinition, Type, Type[])"/> to declare union members.</param>
/// <param name="resolverMethod">The resolver method to execute when this
/// field is requested.</param>
/// <returns>IGraphQLFieldTemplate.</returns>
public static IGraphQLSubscriptionEnabledRuntimeResolvedFieldDefinition MapSubscription(
this ISchemaBuilder schemaBuilder,
string template,
string unionName,
Delegate resolverMethod)
{
Validation.ThrowIfNull(schemaBuilder, nameof(schemaBuilder));

return MapSubscription(
schemaBuilder.Options,
template,
unionName,
resolverMethod);
}

/// <summary>
/// Creates a new field in the Subscription root object with the given path. This field can act as a
/// grouping field of other resolvable fields or be converted to an explicitly resolvable field itself.
/// </summary>
/// <param name="schemaOptions">The options representing the schema where this field
/// will be created.</param>
/// <param name="template">The template path string for his field. (e.g. <c>/path1/path2/path3</c>)</param>
/// <returns>IGraphQLFieldTemplate.</returns>
public static IGraphQLSubscriptionEnabledRuntimeResolvedFieldDefinition MapSubscription(
this SchemaOptions schemaOptions,
string template)
{
return MapSubscription(
schemaOptions,
template,
null, // unionMethod
null as Delegate);
}

/// <summary>
/// Creates a new, explicitly resolvable field in the Subscription root object with the given path. This field cannot be
/// further extended or nested with other fields via the Mapping API.
/// </summary>
/// <param name="schemaOptions">The options representing the schema where this field
/// will be created.</param>
/// <param name="template">The template path string for his field. (e.g. <c>/path1/path2/path3</c>)</param>
/// <param name="resolverMethod">The resolver method to execute when
/// this field is requested by a caller.</param>
/// <returns>IGraphQLResolvedFieldTemplate.</returns>
public static IGraphQLSubscriptionEnabledRuntimeResolvedFieldDefinition MapSubscription(
this SchemaOptions schemaOptions,
string template,
Delegate resolverMethod)
{
return MapSubscription(
schemaOptions,
template,
null, // unionMethod
resolverMethod);
}

/// <summary>
/// Creates a new, explicitly resolvable field in the Subscription root object with the given path. This field cannot be
/// further extended or nested with other fields via the Mapping API.
/// </summary>
/// <param name="schemaOptions">The options representing the schema where this field
/// will be created.</param>
/// <param name="template">The template path string for his field. (e.g. <c>/path1/path2/path3</c>)</param>
/// <param name="unionName">Provide a name and this field will be declared to return a union. Use <see cref="GraphQLRuntimeSchemaItemDefinitionExtensions.AddPossibleTypes(IGraphQLRuntimeResolvedFieldDefinition, Type, Type[])"/> to declare union members.</param>
/// <param name="resolverMethod">The resolver method to execute when
/// this field is requested by a caller.</param>
/// <returns>IGraphQLResolvedFieldTemplate.</returns>
public static IGraphQLSubscriptionEnabledRuntimeResolvedFieldDefinition MapSubscription(
this SchemaOptions schemaOptions,
string template,
string unionName,
Delegate resolverMethod)
{
schemaOptions = Validation.ThrowIfNullOrReturn(schemaOptions, nameof(schemaOptions));
template = Validation.ThrowIfNullWhiteSpaceOrReturn(template, nameof(template));

var fieldTemplate = new RuntimeSubscriptionEnabledFieldGroupTemplate(
schemaOptions,
template);

var resolvedField = RuntimeSubscriptionEnabledResolvedFieldDefinition.FromFieldTemplate(fieldTemplate);
schemaOptions.AddRuntimeSchemaItem(resolvedField);

if (!string.IsNullOrWhiteSpace(unionName))
resolvedField.AddAttribute(new UnionAttribute(unionName.Trim()));

resolvedField.AddResolver(unionName, resolverMethod);

schemaOptions.ServiceCollection?.AddSubscriptionRuntimeFieldExecutionSupport();
return resolvedField;
}

/// <summary>
/// Defines a custom event name for this subscription field. This event name is the key value
/// that must be published from a mutation to invoke this subscription for any subscribers.
/// </summary>
/// <remarks>
/// This event name must be unique for this schema.
/// </remarks>
/// <param name="field">The field to update.</param>
/// <param name="eventName">Name of the event.</param>
/// <returns>IGraphQLSubscriptionEnabledRuntimeResolvedFieldDefinition.</returns>
public static IGraphQLSubscriptionEnabledRuntimeResolvedFieldDefinition WithEventName(
this IGraphQLSubscriptionEnabledRuntimeResolvedFieldDefinition field,
string eventName)
{
field.EventName = eventName;
return field;
}
}
}
Loading
Morty Proxy This is a proxified and sanitized view of the page, visit original site.