You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@sling.apache.org by GitBox <gi...@apache.org> on 2020/10/06 17:06:56 UTC

[GitHub] [sling-org-apache-sling-graphql-core] kozmaadrian commented on a change in pull request #6: SLING-9796 [early review] Adds support for using Unions.

kozmaadrian commented on a change in pull request #6:
URL: https://github.com/apache/sling-org-apache-sling-graphql-core/pull/6#discussion_r500453330



##########
File path: src/main/java/org/apache/sling/graphql/core/engine/SlingTypeResolverSelector.java
##########
@@ -0,0 +1,109 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.sling.graphql.core.engine;
+
+import org.apache.sling.graphql.api.SlingTypeResolver;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.InvalidSyntaxException;
+import org.osgi.framework.ServiceReference;
+import org.osgi.service.component.annotations.Activate;
+import org.osgi.service.component.annotations.Component;
+import org.osgi.service.component.annotations.Reference;
+
+import java.io.IOException;
+
+/**
+ * Selects a SlingTypeProvider used to get the corresponding object type,
+ * based on a name specified by a GraphQL schema directive.
+ */
+@Component(service = SlingTypeResolverSelector.class)
+public class SlingTypeResolverSelector {
+
+    /**
+     * Fetchers which have a name starting with this prefix must be
+     * under the {#link RESERVED_PACKAGE_PREFIX} package.
+     */
+    public static final String RESERVED_NAME_PREFIX = "sling/";
+
+    /**
+     * Package name prefix for fetchers which have names starting
+     * with the {#link RESERVED_NAME_PREFIX}.
+     */
+    public static final String RESERVED_PACKAGE_PREFIX = "org.apache.sling.";
+
+    private BundleContext bundleContext;
+
+    @Reference
+    private ScriptedDataFetcherProvider scriptedDataFetcherProvider;

Review comment:
       Replaced with `ScriptedTypeResolverProvider, extending `getSlingTypeResolver` to call the scripted provider as fallback.

##########
File path: src/main/java/org/apache/sling/graphql/api/SlingTypeResolverEnvironment.java
##########
@@ -0,0 +1,63 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.sling.graphql.api;
+
+import org.apache.sling.api.resource.Resource;
+import org.jetbrains.annotations.Nullable;
+import org.osgi.annotation.versioning.ProviderType;
+
+/**
+ * Provides contextual information to the {#link SlingDataFetcher}
+ */
+@SuppressWarnings("TypeParameterUnusedInFormals")
+
+@ProviderType
+public interface SlingTypeResolverEnvironment {
+
+    /**
+     * @return the current Sling resource
+     */
+    @Nullable
+    Resource getCurrentResource();
+
+    /**
+     * @return the options, if set by the schema directive
+     */
+    @Nullable
+    String getResolverOptions();
+
+    /**
+     * @return the source, if set by the schema directive
+     */
+    @Nullable
+    String getResolverSource();
+
+    /**
+     * @return the GraphQL result item
+     */
+    @Nullable
+    Object getObject();
+
+    /**
+     * @param <T> the type name
+     * @return the GraphQL Object Type
+     */
+    @Nullable <T> T getObjectType(String name);

Review comment:
       Removed `@Nullable`.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org